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
06.07.2020 23:31:50
-3,600
42eeb63744bb2cd95dc9104af7bb5a3c42453130
User request to use C++14 with aligned_alloc
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -84,7 +84,7 @@ EXTERNAL_OBJECTS = $(EXTERNAL_SOURCES:.h=-$(VEC).o)\nBINARY = astcenc-$(VEC)\n-CXXFLAGS = -std=c++17 -fvisibility=hidden -mfpmath=sse \\\n+CXXFLAGS = -std=c++14 -fvisibility=hidden -mfpmath=sse \\\n-Wall -Wextra -Wpedantic -Werror -Werror=shadow -Wdouble-promotion\n# Validate that the DBG parameter is a supported value, and patch CXXFLAGS\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-avx2.vcxproj", "new_path": "Source/VS2019/astcenc-avx2.vcxproj", "diff": "</PrecompiledHeader>\n<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n- <LanguageStandard>stdcpp17</LanguageStandard>\n+ <LanguageStandard>stdcpp14</LanguageStandard>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<StringPooling>true</StringPooling>\n- <LanguageStandard>stdcpp17</LanguageStandard>\n+ <LanguageStandard>stdcpp14</LanguageStandard>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse2.vcxproj", "new_path": "Source/VS2019/astcenc-sse2.vcxproj", "diff": "</PrecompiledHeader>\n<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n- <LanguageStandard>stdcpp17</LanguageStandard>\n+ <LanguageStandard>stdcpp14</LanguageStandard>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<StringPooling>true</StringPooling>\n- <LanguageStandard>stdcpp17</LanguageStandard>\n+ <LanguageStandard>stdcpp14</LanguageStandard>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "new_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "diff": "</PrecompiledHeader>\n<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n- <LanguageStandard>stdcpp17</LanguageStandard>\n+ <LanguageStandard>stdcpp14</LanguageStandard>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<StringPooling>true</StringPooling>\n- <LanguageStandard>stdcpp17</LanguageStandard>\n+ <LanguageStandard>stdcpp14</LanguageStandard>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "#include <cstring>\n#include <new>\n+\n#include \"astcenc.h\"\n#include \"astcenc_internal.h\"\n@@ -533,7 +534,7 @@ static void compress_astc_image(\nint zblocks = (zsize + zdim - 1) / zdim;\n// Allocate temporary buffers. Large, so allocate on the heap\n- auto temp_buffers = std::make_unique<compress_symbolic_block_buffers>();\n+ auto temp_buffers = aligned_malloc<compress_symbolic_block_buffers>(sizeof(compress_symbolic_block_buffers), 32);\nfor (z = 0; z < zblocks; z++)\n{\n@@ -547,7 +548,7 @@ static void compress_astc_image(\nconst uint8_t *bp = buffer + offset;\nfetch_imageblock(decode_mode, &image, &pb, bsd, x * xdim, y * ydim, z * zdim, swizzle);\nsymbolic_compressed_block scb;\n- compress_symbolic_block(&image, decode_mode, bsd, ewp, &pb, &scb, temp_buffers.get());\n+ compress_symbolic_block(&image, decode_mode, bsd, ewp, &pb, &scb, temp_buffers);\n*(physical_compressed_block*) bp = symbolic_to_physical(bsd, &scb);\nctr = ctx.thread_count - 1;\n}\n@@ -558,6 +559,8 @@ static void compress_astc_image(\n}\n}\n}\n+\n+ aligned_free<compress_symbolic_block_buffers>(temp_buffers);\n}\nastcenc_error astcenc_compress_image(\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "#include <cstdio>\n#include <cstdlib>\n#include <condition_variable>\n+#include <malloc.h>\n#include <mutex>\n#ifndef ASTCENC_SSE\n@@ -1083,4 +1084,50 @@ int cpu_supports_popcnt();\n*/\nint cpu_supports_avx2();\n+\n+/**\n+ * @brief Allocate an aligned memory buffer.\n+ *\n+ * Allocated memory must be freed by aligned_free;\n+ *\n+ * @param size The desired buffer size.\n+ * @param align The desired buffer alignment; must be 2^N.\n+ * @returns The memory buffer pointer.\n+ * @throw std::bad_alloc on allocation failure.\n+ */\n+template<typename T>\n+T* aligned_malloc(size_t size, size_t align)\n+{\n+ void* ptr;\n+ int error = 0;\n+\n+#if defined(_WIN32)\n+ ptr = _aligned_malloc(size, align);\n+#else\n+ error = posix_memalign(&ptr, align, size);\n+#endif\n+\n+ if (error || (!ptr))\n+ {\n+ throw std::bad_alloc();\n+ }\n+\n+ return static_cast<T*>(ptr);\n+}\n+\n+/**\n+ * @brief Free an aligned memory buffer.\n+ *\n+ * @param ptr The buffer to free.\n+ */\n+template<typename T>\n+void aligned_free(T* ptr)\n+{\n+#if defined(_WIN32)\n+ _aligned_free(ptr);\n+#else\n+ free(ptr);\n+#endif\n+}\n+\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
User request to use C++14 with aligned_alloc
61,745
07.07.2020 23:02:55
-3,600
a28da24863df3310f4459f9b5afbaed5a8d2f660
Split -perceptual into a stanalone option
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -413,13 +413,12 @@ int init_astcenc_config(\nargidx++;\nflags |= ASTCENC_FLG_USE_ALPHA_WEIGHT;\n}\n- else if (!strcmp(argv[argidx], \"-normal_psnr\"))\n+ else if (!strcmp(argv[argidx], \"-normal\"))\n{\nflags |= ASTCENC_FLG_MAP_NORMAL;\n}\n- else if (!strcmp(argv[argidx], \"-normal_percep\"))\n+ else if (!strcmp(argv[argidx], \"-perceptual\"))\n{\n- flags |= ASTCENC_FLG_MAP_NORMAL;\nflags |= ASTCENC_FLG_USE_PERCEPTUAL;\n}\nelse if (!strcmp(argv[argidx], \"-mask\"))\n@@ -652,7 +651,7 @@ int edit_astcenc_config(\ncli_config.swz_decode.a = swizzle_components[3];\n}\n// presets begin here\n- else if (!strcmp(argv[argidx], \"-normal_psnr\"))\n+ else if (!strcmp(argv[argidx], \"-normal\"))\n{\nargidx++;\n@@ -666,19 +665,9 @@ int edit_astcenc_config(\ncli_config.swz_decode.b = ASTCENC_SWZ_Z;\ncli_config.swz_decode.a = ASTCENC_SWZ_1;\n}\n- else if (!strcmp(argv[argidx], \"-normal_percep\"))\n+ else if (!strcmp(argv[argidx], \"-perceptual\"))\n{\nargidx++;\n-\n- cli_config.swz_encode.r = ASTCENC_SWZ_R;\n- cli_config.swz_encode.g = ASTCENC_SWZ_R;\n- cli_config.swz_encode.b = ASTCENC_SWZ_R;\n- cli_config.swz_encode.a = ASTCENC_SWZ_G;\n-\n- cli_config.swz_decode.r = ASTCENC_SWZ_R;\n- cli_config.swz_decode.g = ASTCENC_SWZ_A;\n- cli_config.swz_decode.b = ASTCENC_SWZ_Z;\n- cli_config.swz_decode.a = ASTCENC_SWZ_1;\n}\nelse if (!strcmp(argv[argidx], \"-mask\"))\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -158,7 +158,7 @@ COMPRESSION\ntrying to minimize the effect of error cross-talk across the\ncolor channels.\n- -normal_psnr\n+ -normal\nThe input texture is a three channel normal map, storing unit\nlength normals as R=X, G=Y, and B=Z, optimized for angular PSNR.\nThe compressor will compress this data as a two channel X+Y\n@@ -168,11 +168,11 @@ COMPRESSION\nZ = sqrt(1 - X^2 - Y^2).\n- -normal_percep\n- The input texture is a three channel normal map, as per\n- -normal_psnr, but is optimized for angular perceptual error.\n- This aims to improves perceptual quality of the normals, but\n- typically lowers the measured PSNR score.\n+ -perceptual\n+ The codec should optimize perceptual error, instead of direct\n+ RMS error. This aims to improves perceived image quality, but\n+ typically lowers the measured PSNR score. Perceptual methods\n+ are currently only available for normal maps.\n-array <size>\nLoads an array of <size> 2D image slices to use as a 3D image.\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -774,7 +774,7 @@ class CLIPTest(CLITestBase):\nrefdB = float(self.exec(command, LDR_RGB_PSNR_PATTERN))\n- command.append(\"-normal_psnr\")\n+ command.append(\"-normal\")\ntestdB = float(self.exec(command, LDR_RGB_PSNR_PATTERN))\n# Note that this test simply asserts that the \"-normal_psnr\" is\n@@ -795,10 +795,11 @@ class CLIPTest(CLITestBase):\nrefdB = float(self.exec(command, LDR_RGB_PSNR_PATTERN))\n- command.append(\"-normal_percep\")\n+ command.append(\"-normal\")\n+ command.append(\"-perceptual\")\ntestdB = float(self.exec(command, LDR_RGB_PSNR_PATTERN))\n- # Note that this test simply asserts that the \"-normal_percep\" is\n+ # Note that this test simply asserts that the \"-normal -percep\" is\n# connected and affects the output. We don't test it does something\n# useful; that it outside the scope of this test case.\nself.assertNotEqual(refdB, testdB)\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/encoder.py", "new_path": "Test/testlib/encoder.py", "diff": "@@ -258,7 +258,7 @@ class Encoder2x(EncoderBase):\n]\nif image.colorFormat == \"xy\":\n- command.append(\"-normal_psnr\")\n+ command.append(\"-normal\")\nif image.isMask:\ncommand.append(\"-mask\")\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Split -perceptual into a stanalone option
61,745
07.07.2020 23:12:39
-3,600
509671b95de2be87b9f7d99b53ddd8e71e17d757
Update markdown with latest 2.x updates
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "# Building ASTC Encoder\nThis page provides instructions for building `astcenc` from the sources in\n-this repository.\n-\n-**Note:** The current `master` branch is configured to statically build\n+this repository. The current `master` branch is configured to statically build\nbinaries which each use a specific level of SIMD support (SSE2, SSE4.2,\nor AVX2) selected at compile time. Binaries are produced with a name postfix\nindicating the SIMD type in use; e.g. `astcenc-avx2` for the AVX2 binary.\n@@ -35,21 +33,22 @@ msbuild astcenc.sln /p:Configuration=Release /p:Platform=x64\n## macOS and Linux\n-Builds for macOS and Linux use GCC and Make, and are tested with GCC 7.4 and\n-GNU Make 3.82.\n+Builds for macOS and Linux use GCC or Clang and Make. They are tested using\n+Clang 9.0, GCC 7.4, and Make 3.82. Using Clang 9.0 is recommended, as Clang\n+builds out-perform GCC builds by approximately 20% in benchmarked test runs.\n### Single variants\nTo compile a single SIMD variant compile with:\n```\n-make -sC Source VEC=[nointrin|sse2|sse4.2|avx2] -j8\n+make -C Source CXX=clang++ VEC=[nointrin|sse2|sse4.2|avx2] -j8\n```\n... and use:\n```\n-make -sC Source VEC=[nointrin|sse2|sse4.2|avx2] clean\n+make -C Source CXX=clang++ VEC=[nointrin|sse2|sse4.2|avx2] clean\n```\n... to clean the build.\n@@ -59,7 +58,7 @@ make -sC Source VEC=[nointrin|sse2|sse4.2|avx2] clean\nTo compile all supported SIMD variants compile with:\n```\n-make -sC Source batchbuild -j8\n+make -sC Source CXX=clang++ batchbuild -j8\n```\n... and use:\n" }, { "change_type": "MODIFY", "old_path": "Docs/Encoding.md", "new_path": "Docs/Encoding.md", "diff": "@@ -151,9 +151,9 @@ the RGB color channels in some circumstances:\n## Encoding normal maps\nThe best way to store normal maps using ASTC is similar to the scheme used by\n-BC5; store the X and Y components of a unit-length tangent space normal. The\n-Z component of the normal can be reconstructed in shader code based on the\n-knowledge that the vector is unit length.\n+BC5; store the X and Y components of a unit-length normal. The Z component of\n+the normal can be reconstructed in shader code based on the knowledge that the\n+vector is unit length.\nTo encode this we therefore want to store two input channels and should\ntherefore use the `rrrg` coding swizzle, and the `.ga` sampling swizzle. The\n@@ -163,9 +163,17 @@ OpenGL ES shader code for reconstruction of the Z value is:\nnormal.xy = texture(...).ga;\nnormal.z = sqrt(1 - dot(normal.xy, normal.xy));\n-In addition to this it is useful to use the `-normal_psnr` command line\n-option, which switches the compressor to optimize for angular error in the\n-resulting vector rather than for absolute color error in the data.\n+In addition to this it is useful to optimize for angular error in the resulting\n+vector rather than for absolute color error in the data, which improves the\n+perceptual quality of the image.\n+\n+Both the encoding swizzle and the angular error function are enabled by using\n+the `-normal` command line option. Normal map compression additionally supports\n+a dedicated perceptual error mode, enabled with the `-perceptual` switch, which\n+also optimizes for variance in the normal vector over a small neighborhood.\n+This can improve perceived visual quality by reducing variability that is\n+amplified by specular lighting calculations, but it will reduce the apparent\n+PSNR of the image.\n## Encoding sRGB data\n@@ -191,9 +199,9 @@ handling the alpha channel.\nFor many use cases the alpha channel is an actual alpha opacity channel and is\ntherefore used for storing an LDR value between 0 and 1. For these cases use\n-the `-hdr` compressor option which will treat the RGB channels as HDR, but the\n+the `-ch` compressor option which will treat the RGB channels as HDR, but the\nA channel as LDR.\nFor other use cases the alpha channel is simply a fourth data channel which is\n-also storing an HDR value. For these cases use the `-hdra` compressor option\n+also storing an HDR value. For these cases use the `-cH` compressor option\nwhich will treat all channels as HDR data.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update markdown with latest 2.x updates
61,745
07.07.2020 23:17:07
-3,600
5a16f1da9036d55d058c99920a778c41cd6a7a10
Remove obsolete markdown file
[ { "change_type": "DELETE", "old_path": "Docs/BranchNotes.md", "new_path": null, "diff": "-# Branch 2.0 design notes\n-\n-# Objectives\n-\n-The aim of the 2.0 work is to achieve the equivalent of `-thorough` encoding\n-quality with `-medium` performance. This equates to an ~8x performance\n-improvement over the version 1.x codec, at the same output quality, and without\n-losing any of the format features (e.g. block sizes and modes) currently\n-supported.\n-\n-There are four main approaches which will be used to achieve this.\n-\n-* Code simplification\n-* Datapath restructuring\n-* Algorithm tuning\n-* CPU SIMD vectorization\n-\n-We are currently focussing on the code simplification and algorithm review.\n-\n-## Code simplification\n-\n-The version 1.0 codec was initially developed as part of the the ASTC format\n-design, evolving as the format was developed and refined. A lot of the v1.x\n-implementation was therefore built to be modular and easy to adapt as the\n-format design changed, rather than for the best possible performance. Now that\n-the format has been published we can review all of the existing code, and\n-rework it for performance rather than ease of modification.\n-\n-## Datapath restructuring\n-\n-The current code does one block at a time, in a depth-first search with full\n-iterative refinement at each stage until the target quality is either hit or we\n-run out of codec options to try. This approach is easier to understand, but the\n-resulting code is control plane heavy and includes a lot of overhead which\n-cannot be amortized over multiple blocks. As a first step for SIMD\n-vectorization the data path must be reviewed to make sure that it can be\n-vectorized efficiently.\n-\n-* Batching processing passes for multiple blocks.\n-* Reducing branching and branch divergence to allow SIMD batching.\n-* Reducing scatter/gather loads to ensure efficient memory access.\n-* Amortizing memory access cost over multiple blocks\n-\n-The restructure becomes particular important with an eye on a long-term\n-objective (v3?) to support compression passes running on a GPU, as it is\n-necessary to offload relatively large batches of work, while also avoiding\n-bottle necking GPU performance on memory access overheads rather than useful\n-processing.\n-\n-## Algorithm tuning\n-\n-As part of the restructuring we will review the effectiveness of the existing\n-optimization passes that we have in the code, to see what can be removed. We\n-know that some passes are expensive and/or difficult to vectorize, and do not\n-actually justify that cost in significant quality improvements.\n-\n-In addition many math library operations will be reviewed and replaced with\n-faster implementations which are less accurate but more friendly towards\n-vectorization in future.\n-\n-## CPU SIMD vectorization\n-\n-The final stage, once we are happy with the data path design, will be to look\n-at implementing a true SIMD data path for the CPU. This could be done using\n-manual SIMD code, such as intrinsics, or a compiled SIMD generator,\n-such as ISPC; the decision here can happen later.\n-\n-# TODOs\n-\n-* The `double4` vector type doesn't vectorize well with SIMD; it should be\n- removed, but this probably means we need a new algorithm for that part\n- of the code.\n-* Remove globals.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove obsolete markdown file
61,745
08.07.2020 20:29:39
-3,600
cc5309fbda6198f70be789ffa27c280a6a46958a
Move avg/var data to the context
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -809,7 +809,7 @@ static float prepare_error_weight_block(\nif (any_mean_stdev_weight)\n{\n- float4 avg = input_image->input_averages[zpos * zdt + ypos * ydt + xpos];\n+ float4 avg = ctx.input_averages[zpos * zdt + ypos * ydt + xpos];\nif (avg.x < 6e-5f)\navg.x = 6e-5f;\nif (avg.y < 6e-5f)\n@@ -821,7 +821,7 @@ static float prepare_error_weight_block(\navg = avg * avg;\n- float4 variance = input_image->input_variances[zpos * zdt + ypos * ydt + xpos];\n+ float4 variance = ctx.input_variances[zpos * zdt + ypos * ydt + xpos];\nvariance = variance * variance;\nfloat favg = (avg.x + avg.y + avg.z) * (1.0f / 3.0f);\n@@ -877,7 +877,7 @@ static float prepare_error_weight_block(\n{\nfloat alpha_scale;\nif (ctx.config.a_scale_radius != 0)\n- alpha_scale = input_image->input_alpha_averages[zpos * zdt + ypos * ydt + xpos];\n+ alpha_scale = ctx.input_alpha_averages[zpos * zdt + ypos * ydt + xpos];\nelse\nalpha_scale = blk->orig_data[4 * idx + 3];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -109,6 +109,7 @@ static void compute_pixel_region_variance(\nconst pixel_region_variance_args* arg\n) {\n// Unpack the memory structure into local variables\n+ const astcenc_context* ctx = arg->ctx;\nconst astc_codec_image* img = arg->img;\nfloat rgb_power = arg->rgb_power;\nfloat alpha_power = arg->alpha_power;\n@@ -130,9 +131,9 @@ static void compute_pixel_region_variance(\nint avg_var_kernel_radius = arg->avg_var_kernel_radius;\nint alpha_kernel_radius = arg->alpha_kernel_radius;\n- float *input_alpha_averages = img->input_alpha_averages;\n- float4 *input_averages = img->input_averages;\n- float4 *input_variances = img->input_variances;\n+ float *input_alpha_averages = ctx->input_alpha_averages;\n+ float4 *input_averages = ctx->input_averages;\n+ float4 *input_variances = ctx->input_variances;\nfloat4 *work_memory = arg->work_memory;\n// Compute memory sizes and dimensions that we need\n@@ -532,7 +533,8 @@ void compute_averages_and_variances(\n/* Public function, see header file for detailed documentation */\nvoid init_compute_averages_and_variances(\n- astc_codec_image* img,\n+ astcenc_context& ctx,\n+ astc_codec_image& img,\nfloat rgb_power,\nfloat alpha_power,\nint avg_var_kernel_radius,\n@@ -541,19 +543,9 @@ void init_compute_averages_and_variances(\npixel_region_variance_args& arg,\navg_var_args& ag\n) {\n- int size_x = img->xsize;\n- int size_y = img->ysize;\n- int size_z = img->zsize;\n- int pixel_count = size_x * size_y * size_z;\n-\n- // Perform memory allocations for the destination buffers\n- delete[] img->input_averages;\n- delete[] img->input_variances;\n- delete[] img->input_alpha_averages;\n-\n- img->input_averages = new float4[pixel_count];\n- img->input_variances = new float4[pixel_count];\n- img->input_alpha_averages = new float[pixel_count];\n+ int size_x = img.xsize;\n+ int size_y = img.ysize;\n+ int size_z = img.zsize;\n// Compute maximum block size and from that the working memory buffer size\nint kernel_radius = MAX(avg_var_kernel_radius, alpha_kernel_radius);\n@@ -573,7 +565,8 @@ void init_compute_averages_and_variances(\narg.dst_offset = int3(0, 0, 0);\narg.work_memory = nullptr;\n- arg.img = img;\n+ arg.ctx = &ctx;\n+ arg.img = &img;\narg.rgb_power = rgb_power;\narg.alpha_power = alpha_power;\narg.swz = swz;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -460,6 +460,11 @@ astcenc_error astcenc_context_alloc(\nctx->thread_count = thread_count;\nctx->config = config;\n+ // Clear scratch storage (allocated per compress pass)\n+ ctx->input_averages = nullptr;\n+ ctx->input_variances = nullptr;\n+ ctx->input_alpha_averages = nullptr;\n+\n// Copy the config first and validate the copy (may modify it)\nstatus = validate_config(ctx->config);\nif (status != ASTCENC_SUCCESS)\n@@ -518,7 +523,7 @@ void astcenc_context_free(\n}\n}\n-static void compress_astc_image(\n+static void compress_image(\nastcenc_context& ctx,\nconst astc_codec_image& image,\nastcenc_swizzle swizzle,\n@@ -617,10 +622,6 @@ astcenc_error astcenc_compress_image(\ninput_image.zsize = image.dim_z;\ninput_image.padding = image.dim_pad;\n- input_image.input_averages = nullptr;\n- input_image.input_variances = nullptr;\n- input_image.input_alpha_averages = nullptr;\n-\n// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nctx->barrier->wait();\n@@ -630,8 +631,14 @@ astcenc_error astcenc_compress_image(\n{\nif (thread_index == 0)\n{\n+ // Perform memory allocations for the destination buffers\n+ size_t texel_count = image.dim_x * image.dim_y * image.dim_z;\n+ ctx->input_averages = new float4[texel_count];\n+ ctx->input_variances = new float4[texel_count];\n+ ctx->input_alpha_averages = new float[texel_count];\n+\ninit_compute_averages_and_variances(\n- &input_image, ctx->config.v_rgb_power, ctx->config.v_a_power,\n+ *ctx, input_image, ctx->config.v_rgb_power, ctx->config.v_a_power,\nctx->config.v_rgba_radius, ctx->config.a_scale_radius, swizzle,\nctx->arg, ctx->ag);\n}\n@@ -645,7 +652,7 @@ astcenc_error astcenc_compress_image(\n// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nctx->barrier->wait();\n- compress_astc_image(*ctx, input_image, swizzle, data_out, thread_index);\n+ compress_image(*ctx, input_image, swizzle, data_out, thread_index);\n// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nctx->barrier->wait();\n@@ -653,9 +660,14 @@ astcenc_error astcenc_compress_image(\n// Clean up any memory allocated by compute_averages_and_variances\nif (thread_index == 0)\n{\n- delete[] input_image.input_averages;\n- delete[] input_image.input_variances;\n- delete[] input_image.input_alpha_averages;\n+ delete[] ctx->input_averages;\n+ ctx->input_averages = nullptr;\n+\n+ delete[] ctx->input_variances;\n+ ctx->input_variances = nullptr;\n+\n+ delete[] ctx->input_alpha_averages;\n+ ctx->input_alpha_averages = nullptr;\n}\nreturn ASTCENC_SUCCESS;\n@@ -700,10 +712,6 @@ astcenc_error astcenc_decompress_image(\nimage.zsize = image_out.dim_z;\nimage.padding = image_out.dim_pad;\n- image.input_averages = nullptr;\n- image.input_variances = nullptr;\n- image.input_alpha_averages = nullptr;\n-\nimageblock pb;\nfor (unsigned int z = 0; z < zblocks; z++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -675,13 +675,6 @@ struct astc_codec_image\nint ysize;\nint zsize;\nint padding;\n-\n- // Regional average-and-variance information, initialized by\n- // compute_averages_and_variances() only if the astc encoder\n- // is requested to do error weighting based on averages and variances.\n- float4 *input_averages;\n- float4 *input_variances;\n- float *input_alpha_averages;\n};\n@@ -693,6 +686,8 @@ struct astc_codec_image\n*/\nstruct pixel_region_variance_args\n{\n+ /** The image to analyze. */\n+ const astcenc_context* ctx;\n/** The image to analyze. */\nconst astc_codec_image* img;\n/** The RGB channel power adjustment. */\n@@ -742,6 +737,13 @@ struct astcenc_context\nfloat deblock_weights[MAX_TEXELS_PER_BLOCK];\n+ // Regional average-and-variance information, initialized by\n+ // compute_averages_and_variances() only if the astc encoder\n+ // is requested to do error weighting based on averages and variances.\n+ float4 *input_averages;\n+ float4 *input_variances;\n+ float *input_alpha_averages;\n+\n// TODO: Replace these with config and input image. Currently here so they\n// can be shared by user thread pool\nastc_codec_image input_image;\n@@ -756,6 +758,7 @@ struct astcenc_context\n* Results are written back into img->input_averages, img->input_variances,\n* and img->input_alpha_averages.\n*\n+ * @param ctxg The context holding intermediate storage.\n* @param img The input image data, also holds output data.\n* @param rgb_power The RGB channel power.\n* @param alpha_power The A channel power.\n@@ -765,7 +768,8 @@ struct astcenc_context\n* @param thread_count The number of threads to use.\n*/\nvoid init_compute_averages_and_variances(\n- astc_codec_image * img,\n+ astcenc_context& ctx,\n+ astc_codec_image& img,\nfloat rgb_power,\nfloat alpha_power,\nint avg_var_kernel_radius,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Move avg/var data to the context
61,745
08.07.2020 21:02:01
-3,600
5286f6ce51e1178f1145f799b1928962e2692282
Remove obsolete astc_codec_image
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -761,7 +761,7 @@ void expand_deblock_weights(\n// Returns the sum of all the error values set.\nstatic float prepare_error_weight_block(\nconst astcenc_context& ctx,\n- const astc_codec_image* input_image,\n+ const astcenc_image& input_image,\nconst block_size_descriptor* bsd,\nconst imageblock* blk,\nerror_weight_block* ewb,\n@@ -787,11 +787,11 @@ static float prepare_error_weight_block(\n{\nfor (int x = 0; x < bsd->xdim; x++)\n{\n- int xpos = x + blk->xpos;\n- int ypos = y + blk->ypos;\n- int zpos = z + blk->zpos;\n+ unsigned int xpos = x + blk->xpos;\n+ unsigned int ypos = y + blk->ypos;\n+ unsigned int zpos = z + blk->zpos;\n- if (xpos >= input_image->xsize || ypos >= input_image->ysize || zpos >= input_image->zsize)\n+ if (xpos >= input_image.dim_x || ypos >= input_image.dim_y || zpos >= input_image.dim_z)\n{\nfloat4 weights = float4(1e-11f, 1e-11f, 1e-11f, 1e-11f);\newb->error_weights[idx] = weights;\n@@ -804,8 +804,8 @@ static float prepare_error_weight_block(\nctx.config.v_rgb_base,\nctx.config.v_a_base);\n- int ydt = input_image->xsize;\n- int zdt = input_image->xsize * input_image->ysize;\n+ int ydt = input_image.dim_x;\n+ int zdt = input_image.dim_x * input_image.dim_y;\nif (any_mean_stdev_weight)\n{\n@@ -1064,7 +1064,7 @@ static void prepare_block_statistics(\nfloat compress_symbolic_block(\nconst astcenc_context& ctx,\n- const astc_codec_image* input_image,\n+ const astcenc_image& input_image,\nastcenc_profile decode_mode,\nconst block_size_descriptor* bsd,\nconst imageblock* blk,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -110,7 +110,7 @@ static void compute_pixel_region_variance(\n) {\n// Unpack the memory structure into local variables\nconst astcenc_context* ctx = arg->ctx;\n- const astc_codec_image* img = arg->img;\n+ const astcenc_image* img = arg->img;\nfloat rgb_power = arg->rgb_power;\nfloat alpha_power = arg->alpha_power;\nastcenc_swizzle swz = arg->swz;\n@@ -158,8 +158,8 @@ static void compute_pixel_region_variance(\nint zst = padsize_x * padsize_y;\n// Scaling factors to apply to Y and Z for accesses into result buffers\n- int ydt = img->xsize;\n- int zdt = img->xsize * img->ysize;\n+ int ydt = img->dim_x;\n+ int zdt = img->dim_x * img->dim_y;\n// Macros to act as accessor functions for the work-memory\n#define VARBUF1(z, y, x) varbuf1[z * zst + y * yst + x]\n@@ -496,7 +496,7 @@ void compute_averages_and_variances(\nint step_y = ag.blk_size.y;\nint step_z = ag.blk_size.z;\n- int padding_xy = arg.img->padding;\n+ int padding_xy = arg.img->dim_pad;\nint padding_z = arg.have_z ? padding_xy : 0;\nfor (int z = 0; z < size_z; z += step_z)\n@@ -534,7 +534,7 @@ void compute_averages_and_variances(\n/* Public function, see header file for detailed documentation */\nvoid init_compute_averages_and_variances(\nastcenc_context& ctx,\n- astc_codec_image& img,\n+ astcenc_image& img,\nfloat rgb_power,\nfloat alpha_power,\nint avg_var_kernel_radius,\n@@ -543,9 +543,9 @@ void init_compute_averages_and_variances(\npixel_region_variance_args& arg,\navg_var_args& ag\n) {\n- int size_x = img.xsize;\n- int size_y = img.ysize;\n- int size_z = img.zsize;\n+ int size_x = img.dim_x;\n+ int size_y = img.dim_y;\n+ int size_z = img.dim_z;\n// Compute maximum block size and from that the working memory buffer size\nint kernel_radius = MAX(avg_var_kernel_radius, alpha_kernel_radius);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -525,44 +525,42 @@ void astcenc_context_free(\nstatic void compress_image(\nastcenc_context& ctx,\n- const astc_codec_image& image,\n+ const astcenc_image& image,\nastcenc_swizzle swizzle,\nuint8_t* buffer,\nint thread_id\n) {\nconst block_size_descriptor *bsd = ctx.bsd;\n- int xdim = bsd->xdim;\n- int ydim = bsd->ydim;\n- int zdim = bsd->zdim;\n+ int block_x = bsd->xdim;\n+ int block_y = bsd->ydim;\n+ int block_z = bsd->zdim;\nastcenc_profile decode_mode = ctx.config.profile;\nimageblock pb;\nint ctr = thread_id;\n-\n- int x, y, z;\n- int xsize = image.xsize;\n- int ysize = image.ysize;\n- int zsize = image.zsize;\n- int xblocks = (xsize + xdim - 1) / xdim;\n- int yblocks = (ysize + ydim - 1) / ydim;\n- int zblocks = (zsize + zdim - 1) / zdim;\n+ int dim_x = image.dim_x;\n+ int dim_y = image.dim_y;\n+ int dim_z = image.dim_z;\n+ int xblocks = (dim_x + block_x - 1) / block_x;\n+ int yblocks = (dim_y + block_y - 1) / block_y;\n+ int zblocks = (dim_z + block_z - 1) / block_z;\n// Allocate temporary buffers. Large, so allocate on the heap\nauto temp_buffers = aligned_malloc<compress_symbolic_block_buffers>(sizeof(compress_symbolic_block_buffers), 32);\n- for (z = 0; z < zblocks; z++)\n+ for (int z = 0; z < zblocks; z++)\n{\n- for (y = 0; y < yblocks; y++)\n+ for (int y = 0; y < yblocks; y++)\n{\n- for (x = 0; x < xblocks; x++)\n+ for (int x = 0; x < xblocks; x++)\n{\nif (ctr == 0)\n{\nint offset = ((z * yblocks + y) * xblocks + x) * 16;\nconst uint8_t *bp = buffer + offset;\n- fetch_imageblock(decode_mode, &image, &pb, bsd, x * xdim, y * ydim, z * zdim, swizzle);\n+ fetch_imageblock(decode_mode, image, &pb, bsd, x * block_x, y * block_y, z * block_z, swizzle);\nsymbolic_compressed_block scb;\n- compress_symbolic_block(ctx, &image, decode_mode, bsd, &pb, &scb, temp_buffers);\n+ compress_symbolic_block(ctx, image, decode_mode, bsd, &pb, &scb, temp_buffers);\n*(physical_compressed_block*) bp = symbolic_to_physical(bsd, &scb);\nctr = ctx.thread_count - 1;\n}\n@@ -613,15 +611,6 @@ astcenc_error astcenc_compress_image(\nreturn ASTCENC_ERR_OUT_OF_MEM;\n}\n- // TODO: Replace astc_codec_image in the core codec with the astcenc_image struct\n- astc_codec_image& input_image = ctx->input_image;\n- input_image.data8 = image.data8;\n- input_image.data16 = image.data16;\n- input_image.xsize = image.dim_x;\n- input_image.ysize = image.dim_y;\n- input_image.zsize = image.dim_z;\n- input_image.padding = image.dim_pad;\n-\n// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nctx->barrier->wait();\n@@ -638,7 +627,7 @@ astcenc_error astcenc_compress_image(\nctx->input_alpha_averages = new float[texel_count];\ninit_compute_averages_and_variances(\n- *ctx, input_image, ctx->config.v_rgb_power, ctx->config.v_a_power,\n+ *ctx, image, ctx->config.v_rgb_power, ctx->config.v_a_power,\nctx->config.v_rgba_radius, ctx->config.a_scale_radius, swizzle,\nctx->arg, ctx->ag);\n}\n@@ -652,7 +641,7 @@ astcenc_error astcenc_compress_image(\n// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nctx->barrier->wait();\n- compress_image(*ctx, input_image, swizzle, data_out, thread_index);\n+ compress_image(*ctx, image, swizzle, data_out, thread_index);\n// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nctx->barrier->wait();\n@@ -703,15 +692,6 @@ astcenc_error astcenc_decompress_image(\nreturn ASTCENC_ERR_OUT_OF_MEM;\n}\n- // TODO: Replace astc_codec_image in the core codec with the astcenc_image struct\n- astc_codec_image image;\n- image.data8 = image_out.data8;\n- image.data16 = image_out.data16;\n- image.xsize = image_out.dim_x;\n- image.ysize = image_out.dim_y;\n- image.zsize = image_out.dim_z;\n- image.padding = image_out.dim_pad;\n-\nimageblock pb;\nfor (unsigned int z = 0; z < zblocks; z++)\n@@ -728,7 +708,7 @@ astcenc_error astcenc_decompress_image(\ndecompress_symbolic_block(context->config.profile, context->bsd,\nx * block_x, y * block_y, z * block_z,\n&scb, &pb);\n- write_imageblock(&image, &pb, context->bsd,\n+ write_imageblock(image_out, &pb, context->bsd,\nx * block_x, y * block_y, z * block_z, swizzle);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -248,7 +248,7 @@ void imageblock_initialize_orig_from_work(\n// fetch an imageblock from the input file.\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\n- const astc_codec_image* img,\n+ const astcenc_image& img,\nimageblock* pb, // picture-block to initialize with image data\nconst block_size_descriptor* bsd,\n// position in texture.\n@@ -258,9 +258,9 @@ void fetch_imageblock(\nastcenc_swizzle swz\n) {\nfloat *fptr = pb->orig_data;\n- int xsize = img->xsize + 2 * img->padding;\n- int ysize = img->ysize + 2 * img->padding;\n- int zsize = (img->zsize == 1) ? 1 : img->zsize + 2 * img->padding;\n+ int xsize = img.dim_x + 2 * img.dim_pad;\n+ int ysize = img.dim_y + 2 * img.dim_pad;\n+ int zsize = (img.dim_z == 1) ? 1 : img.dim_z + 2 * img.dim_pad;\nint x, y, z, i;\n@@ -268,16 +268,18 @@ void fetch_imageblock(\npb->ypos = ypos;\npb->zpos = zpos;\n- xpos += img->padding;\n- ypos += img->padding;\n- if (img->zsize > 1)\n- zpos += img->padding;\n+ xpos += img.dim_pad;\n+ ypos += img.dim_pad;\n+ if (img.dim_z > 1)\n+ {\n+ zpos += img.dim_pad;\n+ }\nfloat data[6];\ndata[4] = 0;\ndata[5] = 1;\n- if (img->data8)\n+ if (img.data8)\n{\nfor (z = 0; z < bsd->zdim; z++)\n{\n@@ -302,10 +304,10 @@ void fetch_imageblock(\nif (zi >= zsize)\nzi = zsize - 1;\n- int r = img->data8[zi][yi][4 * xi];\n- int g = img->data8[zi][yi][4 * xi + 1];\n- int b = img->data8[zi][yi][4 * xi + 2];\n- int a = img->data8[zi][yi][4 * xi + 3];\n+ int r = img.data8[zi][yi][4 * xi];\n+ int g = img.data8[zi][yi][4 * xi + 1];\n+ int b = img.data8[zi][yi][4 * xi + 2];\n+ int a = img.data8[zi][yi][4 * xi + 3];\ndata[0] = r / 255.0f;\ndata[1] = g / 255.0f;\n@@ -322,7 +324,7 @@ void fetch_imageblock(\n}\n}\n}\n- else if (img->data16)\n+ else if (img.data16)\n{\nfor (z = 0; z < bsd->zdim; z++)\n{\n@@ -347,10 +349,10 @@ void fetch_imageblock(\nif (zi >= ysize)\nzi = zsize - 1;\n- int r = img->data16[zi][yi][4 * xi];\n- int g = img->data16[zi][yi][4 * xi + 1];\n- int b = img->data16[zi][yi][4 * xi + 2];\n- int a = img->data16[zi][yi][4 * xi + 3];\n+ int r = img.data16[zi][yi][4 * xi];\n+ int g = img.data16[zi][yi][4 * xi + 1];\n+ int b = img.data16[zi][yi][4 * xi + 2];\n+ int a = img.data16[zi][yi][4 * xi + 3];\nfloat rf = sf16_to_float(r);\nfloat gf = sf16_to_float(g);\n@@ -394,7 +396,7 @@ void fetch_imageblock(\n}\nvoid write_imageblock(\n- astc_codec_image* img,\n+ astcenc_image& img,\nconst imageblock* pb, // picture-block to initialize with image data. We assume that orig_data is valid.\nconst block_size_descriptor* bsd,\n// position to write the block to\n@@ -405,16 +407,16 @@ void write_imageblock(\n) {\nconst float *fptr = pb->orig_data;\nconst uint8_t *nptr = pb->nan_texel;\n- int xsize = img->xsize;\n- int ysize = img->ysize;\n- int zsize = img->zsize;\n+ int xsize = img.dim_x;\n+ int ysize = img.dim_y;\n+ int zsize = img.dim_z;\nint x, y, z;\nfloat data[7];\ndata[4] = 0.0f;\ndata[5] = 1.0f;\n- if (img->data8)\n+ if (img.data8)\n{\nfor (z = 0; z < bsd->zdim; z++)\n{\n@@ -431,10 +433,10 @@ void write_imageblock(\nif (*nptr)\n{\n// NaN-pixel, but we can't display it. Display purple instead.\n- img->data8[zi][yi][4 * xi] = 0xFF;\n- img->data8[zi][yi][4 * xi + 1] = 0x00;\n- img->data8[zi][yi][4 * xi + 2] = 0xFF;\n- img->data8[zi][yi][4 * xi + 3] = 0xFF;\n+ img.data8[zi][yi][4 * xi] = 0xFF;\n+ img.data8[zi][yi][4 * xi + 1] = 0x00;\n+ img.data8[zi][yi][4 * xi + 2] = 0xFF;\n+ img.data8[zi][yi][4 * xi + 3] = 0xFF;\n}\nelse\n{\n@@ -466,10 +468,10 @@ void write_imageblock(\nint bi = astc::flt2int_rtn(data[swz.b] * 255.0f);\nint ai = astc::flt2int_rtn(data[swz.a] * 255.0f);\n- img->data8[zi][yi][4 * xi] = ri;\n- img->data8[zi][yi][4 * xi + 1] = gi;\n- img->data8[zi][yi][4 * xi + 2] = bi;\n- img->data8[zi][yi][4 * xi + 3] = ai;\n+ img.data8[zi][yi][4 * xi] = ri;\n+ img.data8[zi][yi][4 * xi + 1] = gi;\n+ img.data8[zi][yi][4 * xi + 2] = bi;\n+ img.data8[zi][yi][4 * xi + 3] = ai;\n}\n}\nfptr += 4;\n@@ -478,7 +480,7 @@ void write_imageblock(\n}\n}\n}\n- else if (img->data16)\n+ else if (img.data16)\n{\nfor (z = 0; z < bsd->zdim; z++)\n{\n@@ -494,10 +496,10 @@ void write_imageblock(\n{\nif (*nptr)\n{\n- img->data16[zi][yi][4 * xi] = 0xFFFF;\n- img->data16[zi][yi][4 * xi + 1] = 0xFFFF;\n- img->data16[zi][yi][4 * xi + 2] = 0xFFFF;\n- img->data16[zi][yi][4 * xi + 3] = 0xFFFF;\n+ img.data16[zi][yi][4 * xi] = 0xFFFF;\n+ img.data16[zi][yi][4 * xi + 1] = 0xFFFF;\n+ img.data16[zi][yi][4 * xi + 2] = 0xFFFF;\n+ img.data16[zi][yi][4 * xi + 3] = 0xFFFF;\n}\nelse\n@@ -518,10 +520,10 @@ void write_imageblock(\nint g = float_to_sf16(data[swz.g], SF_NEARESTEVEN);\nint b = float_to_sf16(data[swz.b], SF_NEARESTEVEN);\nint a = float_to_sf16(data[swz.a], SF_NEARESTEVEN);\n- img->data16[zi][yi][4 * xi] = r;\n- img->data16[zi][yi][4 * xi + 1] = g;\n- img->data16[zi][yi][4 * xi + 2] = b;\n- img->data16[zi][yi][4 * xi + 3] = a;\n+ img.data16[zi][yi][4 * xi] = r;\n+ img.data16[zi][yi][4 * xi + 1] = g;\n+ img.data16[zi][yi][4 * xi + 2] = b;\n+ img.data16[zi][yi][4 * xi + 3] = a;\n}\n}\nfptr += 4;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -667,17 +667,6 @@ void kmeans_compute_partition_ordering(\n// functions and data pertaining to images and imageblocks\n// *********************************************************\n-struct astc_codec_image\n-{\n- uint8_t ***data8;\n- uint16_t ***data16;\n- int xsize;\n- int ysize;\n- int zsize;\n- int padding;\n-};\n-\n-\n/**\n* @brief Parameter structure for compute_pixel_region_variance().\n*\n@@ -689,7 +678,7 @@ struct pixel_region_variance_args\n/** The image to analyze. */\nconst astcenc_context* ctx;\n/** The image to analyze. */\n- const astc_codec_image* img;\n+ const astcenc_image* img;\n/** The RGB channel power adjustment. */\nfloat rgb_power;\n/** The alpha channel power adjustment. */\n@@ -744,10 +733,6 @@ struct astcenc_context\nfloat4 *input_variances;\nfloat *input_alpha_averages;\n- // TODO: Replace these with config and input image. Currently here so they\n- // can be shared by user thread pool\n- astc_codec_image input_image;\n-\n// Thread management\nBarrier* barrier;\n};\n@@ -769,7 +754,7 @@ struct astcenc_context\n*/\nvoid init_compute_averages_and_variances(\nastcenc_context& ctx,\n- astc_codec_image& img,\n+ astcenc_image& img,\nfloat rgb_power,\nfloat alpha_power,\nint avg_var_kernel_radius,\n@@ -786,7 +771,7 @@ void compute_averages_and_variances(\n// fetch an image-block from the input file\nvoid fetch_imageblock(\nastcenc_profile decode_mode,\n- const astc_codec_image* img,\n+ const astcenc_image& img,\nimageblock* pb, // picture-block to initialize with image data\nconst block_size_descriptor* bsd,\n// position in picture to fetch block from\n@@ -798,7 +783,7 @@ void fetch_imageblock(\n// write an image block to the output file buffer.\n// the data written are taken from orig_data.\nvoid write_imageblock(\n- astc_codec_image* img,\n+ astcenc_image& img,\nconst imageblock* pb, // picture-block to initialize with image data\nconst block_size_descriptor* bsd,\n// position in picture to write block to.\n@@ -1005,7 +990,7 @@ void compute_angular_endpoints_2planes(\nfloat compress_symbolic_block(\nconst astcenc_context& ctx,\n- const astc_codec_image* input_image,\n+ const astcenc_image& image,\nastcenc_profile decode_mode,\nconst block_size_descriptor* bsd,\nconst imageblock* blk,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove obsolete astc_codec_image
61,745
09.07.2020 00:52:21
-3,600
00f4bb57d7c2c1085938c809801fb9f82482a4eb
Fix block-size determination for decode passes
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -344,7 +344,7 @@ int init_astcenc_config(\n{\nblock_x = comp_image.block_x;\nblock_y = comp_image.block_y;\n- block_z = comp_image.block_y;\n+ block_z = comp_image.block_z;\n}\nastcenc_preset preset = ASTCENC_PRE_FAST;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix block-size determination for decode passes
61,745
09.07.2020 01:01:42
-3,600
cf6d078eea4c95bb55dbed727d5e7045471c0791
Add regression test for -tl and -cl/-dl differing
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -1304,6 +1304,29 @@ class CLIPTest(CLITestBase):\n# somewhere ...\nself.assertLess(len(stdoutSilent), len(stdout))\n+ def test_image_quality_stability(self):\n+ \"\"\"\n+ Test that a round-trip and a file-based round-trip give same result.\n+ \"\"\"\n+ inputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\n+ p1DecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+ p2CompFile = self.get_tmp_image_path(\"LDR\", \"comp\")\n+ p2DecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+\n+ # Compute the first image using a direct round-trip\n+ command = [self.binary, \"-tl\", inputFile, p1DecompFile, \"4x4\", \"-medium\"]\n+ self.exec(command)\n+\n+ # Compute the first image using a file-based round-trip\n+ command = [self.binary, \"-cl\", inputFile, p2CompFile, \"4x4\", \"-medium\"]\n+ self.exec(command)\n+ command = [self.binary, \"-dl\", p2CompFile, p2DecompFile]\n+ self.exec(command)\n+\n+ # RMSE should be the same\n+ p1RMSE = sum(self.get_channel_rmse(inputFile, p1DecompFile))\n+ p2RMSE = sum(self.get_channel_rmse(inputFile, p2DecompFile)))\n+ self.assertEqual(p1RMSE, p2RMSE)\nclass CLINTest(CLITestBase):\n\"\"\"\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add regression test for -tl and -cl/-dl differing
61,745
09.07.2020 08:57:44
-3,600
77c80ce63340632926729cf66e904f6cfeae3c69
Add KTX as a compressed file format option Only supports mip 0; there is no automatic mipmap generation at this point.
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "* @brief Functions for loading/storing ASTC compressed images.\n*/\n+#include <array>\n+#include <cassert>\n#include <cstdio>\n#include <cstdlib>\n#include <cstring>\n@@ -540,6 +542,151 @@ static uint32_t u32_byterev(uint32_t v)\n#define GL_HALF_FLOAT 0x140B\n#define GL_FLOAT 0x1406\n+#define GL_COMPRESSED_RGBA_ASTC_4x4 0x93B0\n+#define GL_COMPRESSED_RGBA_ASTC_5x4 0x93B1\n+#define GL_COMPRESSED_RGBA_ASTC_5x5 0x93B2\n+#define GL_COMPRESSED_RGBA_ASTC_6x5 0x93B3\n+#define GL_COMPRESSED_RGBA_ASTC_6x6 0x93B4\n+#define GL_COMPRESSED_RGBA_ASTC_8x5 0x93B5\n+#define GL_COMPRESSED_RGBA_ASTC_8x6 0x93B6\n+#define GL_COMPRESSED_RGBA_ASTC_8x8 0x93B7\n+#define GL_COMPRESSED_RGBA_ASTC_10x5 0x93B8\n+#define GL_COMPRESSED_RGBA_ASTC_10x6 0x93B9\n+#define GL_COMPRESSED_RGBA_ASTC_10x8 0x93BA\n+#define GL_COMPRESSED_RGBA_ASTC_10x10 0x93BB\n+#define GL_COMPRESSED_RGBA_ASTC_12x10 0x93BC\n+#define GL_COMPRESSED_RGBA_ASTC_12x12 0x93BD\n+\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4 0x93D0\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4 0x93D1\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5 0x93D2\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5 0x93D3\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6 0x93D4\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5 0x93D5\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6 0x93D6\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8 0x93D7\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5 0x93D8\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6 0x93D9\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8 0x93DA\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10 0x93DB\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10 0x93DC\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12 0x93DD\n+\n+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0\n+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1\n+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2\n+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3\n+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4\n+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5\n+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6\n+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7\n+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8\n+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9\n+\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8\n+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9\n+\n+struct format_entry {\n+ unsigned int x;\n+ unsigned int y;\n+ unsigned int z;\n+ bool srgb;\n+ unsigned int format;\n+};\n+\n+static const std::array<format_entry, 48> ASTC_FORMATS =\n+{{\n+ // 2D Linear RGB\n+ { 4, 4, 1, false, GL_COMPRESSED_RGBA_ASTC_4x4},\n+ { 5, 4, 1, false, GL_COMPRESSED_RGBA_ASTC_5x4},\n+ { 5, 5, 1, false, GL_COMPRESSED_RGBA_ASTC_5x5},\n+ { 6, 5, 1, false, GL_COMPRESSED_RGBA_ASTC_6x5},\n+ { 6, 6, 1, false, GL_COMPRESSED_RGBA_ASTC_6x6},\n+ { 8, 5, 1, false, GL_COMPRESSED_RGBA_ASTC_8x5},\n+ { 8, 6, 1, false, GL_COMPRESSED_RGBA_ASTC_8x6},\n+ { 8, 8, 1, false, GL_COMPRESSED_RGBA_ASTC_8x8},\n+ {10, 5, 1, false, GL_COMPRESSED_RGBA_ASTC_10x5},\n+ {10, 6, 1, false, GL_COMPRESSED_RGBA_ASTC_10x6},\n+ {10, 8, 1, false, GL_COMPRESSED_RGBA_ASTC_10x8},\n+ {10, 10, 1, false, GL_COMPRESSED_RGBA_ASTC_10x10},\n+ {12, 10, 1, false, GL_COMPRESSED_RGBA_ASTC_12x10},\n+ {12, 12, 1, false, GL_COMPRESSED_RGBA_ASTC_12x12},\n+ // 2D SRGB\n+ { 4, 4, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4},\n+ { 5, 4, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4},\n+ { 5, 5, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5},\n+ { 6, 5, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5},\n+ { 6, 6, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6},\n+ { 8, 5, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5},\n+ { 8, 6, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6},\n+ { 8, 8, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8},\n+ {10, 5, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5},\n+ {10, 6, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6},\n+ {10, 8, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8},\n+ {10, 10, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10},\n+ {12, 10, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10},\n+ {12, 12, 1, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12},\n+ // 3D Linear RGB\n+ { 3, 3, 3, false, GL_COMPRESSED_RGBA_ASTC_3x3x3_OES},\n+ { 4, 3, 3, false, GL_COMPRESSED_RGBA_ASTC_4x3x3_OES},\n+ { 4, 4, 3, false, GL_COMPRESSED_RGBA_ASTC_4x4x3_OES},\n+ { 4, 4, 4, false, GL_COMPRESSED_RGBA_ASTC_4x4x4_OES},\n+ { 5, 4, 4, false, GL_COMPRESSED_RGBA_ASTC_5x4x4_OES},\n+ { 5, 5, 4, false, GL_COMPRESSED_RGBA_ASTC_5x5x4_OES},\n+ { 5, 5, 5, false, GL_COMPRESSED_RGBA_ASTC_5x5x5_OES},\n+ { 6, 5, 5, false, GL_COMPRESSED_RGBA_ASTC_6x5x5_OES},\n+ { 6, 6, 5, false, GL_COMPRESSED_RGBA_ASTC_6x6x5_OES},\n+ { 6, 6, 6, false, GL_COMPRESSED_RGBA_ASTC_6x6x6_OES},\n+ // 3D SRGB\n+ { 3, 3, 3, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES},\n+ { 4, 3, 3, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES},\n+ { 4, 4, 3, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES},\n+ { 4, 4, 4, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES},\n+ { 5, 4, 4, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES},\n+ { 5, 5, 4, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES},\n+ { 5, 5, 5, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES},\n+ { 6, 5, 5, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES},\n+ { 6, 6, 5, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES},\n+ { 6, 6, 6, true, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES}\n+}};\n+\n+static const format_entry* get_format(\n+ unsigned int format\n+) {\n+ for (auto& it : ASTC_FORMATS)\n+ {\n+ if (it.format == format)\n+ {\n+ return &it;\n+ }\n+ }\n+ return nullptr;\n+}\n+\n+static unsigned int get_format(\n+ unsigned int x,\n+ unsigned int y,\n+ unsigned int z,\n+ bool srgb\n+) {\n+ for (auto& it : ASTC_FORMATS)\n+ {\n+ if ((it.x == x) && (it.y == y) && (it.z == z) && (it.srgb == srgb))\n+ {\n+ return it.format;\n+ }\n+ }\n+ return 0;\n+}\n+\nstruct ktx_header\n{\nuint8_t magic[12];\n@@ -905,6 +1052,136 @@ static astcenc_image* load_ktx_uncompressed_image(\nreturn astc_img;\n}\n+bool load_ktx_compressed_image(\n+ const char* filename,\n+ bool& is_srgb,\n+ astc_compressed_image& img\n+) {\n+ FILE *f = fopen(filename, \"rb\");\n+ if (!f)\n+ {\n+ printf(\"Failed to open file %s\\n\", filename);\n+ return true;\n+ }\n+\n+ ktx_header hdr;\n+ size_t actual = fread(&hdr, 1, sizeof(hdr), f);\n+ if (actual != sizeof(hdr))\n+ {\n+ printf(\"Failed to read header of KTX file %s\\n\", filename);\n+ fclose(f);\n+ return true;\n+ }\n+\n+ if (memcmp(hdr.magic, ktx_magic, 12) != 0 || (hdr.endianness != 0x04030201 && hdr.endianness != 0x01020304))\n+ {\n+ printf(\"File %s does not have a valid KTX header\\n\", filename);\n+ fclose(f);\n+ return true;\n+ }\n+\n+ bool switch_endianness = false;\n+ if (hdr.endianness == 0x01020304)\n+ {\n+ switch_endianness = true;\n+ ktx_header_switch_endianness(&hdr);\n+ }\n+\n+ if (hdr.gl_type != 0 || hdr.gl_format != 0 || hdr.gl_type_size != 1 || hdr.gl_base_internal_format != GL_RGBA)\n+ {\n+ printf(\"File %s is not a compressed ASTC file\\n\", filename);\n+ fclose(f);\n+ return true;\n+ }\n+\n+ const format_entry* fmt = get_format(hdr.gl_internal_format);\n+ if (!fmt)\n+ {\n+ printf(\"File %s is not a compressed ASTC file\\n\", filename);\n+ fclose(f);\n+ return true;\n+ }\n+\n+ unsigned int data_len;\n+ actual = fread(&data_len, 1, sizeof(data_len), f);\n+ if (actual != sizeof(data_len))\n+ {\n+ printf(\"Failed to read data size of KTX file %s\\n\", filename);\n+ fclose(f);\n+ return true;\n+ }\n+\n+ unsigned char* data = new unsigned char[data_len];\n+ actual = fread(data, 1, data_len, f);\n+ if (actual != data_len)\n+ {\n+ printf(\"Failed to data from KTX file %s\\n\", filename);\n+ fclose(f);\n+ return true;\n+ }\n+\n+ if (switch_endianness)\n+ {\n+ data_len = u32_byterev(data_len);\n+ }\n+\n+ img.block_x = fmt->x;\n+ img.block_y = fmt->y;\n+ img.block_z = fmt->z == 0 ? 1 : fmt->z;\n+\n+ img.dim_x = hdr.pixel_width;\n+ img.dim_y = hdr.pixel_height;\n+ img.dim_z = hdr.pixel_depth == 0 ? 1 : hdr.pixel_depth;\n+\n+ img.data_len = data_len;\n+ img.data = data;\n+\n+ is_srgb = fmt->srgb;\n+\n+ return false;\n+}\n+\n+\n+bool store_ktx_compressed_image(\n+ const astc_compressed_image& img,\n+ const char* filename,\n+ bool srgb\n+) {\n+ unsigned int fmt = get_format(img.block_x, img.block_y, img.block_z, srgb);\n+\n+ ktx_header hdr;\n+ memcpy(hdr.magic, ktx_magic, 12);\n+ hdr.endianness = 0x04030201;\n+ hdr.gl_type = 0;\n+ hdr.gl_type_size = 1;\n+ hdr.gl_format = 0;\n+ hdr.gl_internal_format = fmt;\n+ hdr.gl_base_internal_format = GL_RGBA;\n+ hdr.pixel_width = img.dim_x;\n+ hdr.pixel_height = img.dim_y;\n+ hdr.pixel_depth = (img.dim_z == 1) ? 0 : img.dim_z;\n+ hdr.number_of_array_elements = 0;\n+ hdr.number_of_faces = 1;\n+ hdr.number_of_mipmap_levels = 1;\n+ hdr.bytes_of_key_value_data = 0;\n+\n+ size_t expected = sizeof(ktx_header) + 4 + img.data_len;\n+ size_t actual = 0;\n+\n+ FILE *wf = fopen(filename, \"wb\");\n+ actual += fwrite(&hdr, 1, sizeof(ktx_header), wf);\n+ actual += fwrite(&img.data_len, 1, 4, wf);\n+ actual += fwrite(img.data, 1, img.data_len, wf);\n+ fclose(wf);\n+\n+ if (actual != expected)\n+ {\n+ return true;\n+ }\n+\n+ return false;\n+}\n+\nstatic int store_ktx_uncompressed_image(\nconst astcenc_image* img,\nconst char* ktx_filename,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_internal.h", "new_path": "Source/astcenccli_internal.h", "diff": "@@ -107,6 +107,16 @@ int store_cimage(\nconst astc_compressed_image& comp_img,\nconst char* filename);\n+bool load_ktx_compressed_image(\n+ const char* filename,\n+ bool& is_srgb,\n+ astc_compressed_image& img) ;\n+\n+bool store_ktx_compressed_image(\n+ const astc_compressed_image& img,\n+ const char* filename,\n+ bool srgb);\n+\n// helper functions to prepare an ASTC image object from a flat array\n// Used by the image loaders in \"astc_file_load_store.cpp\"\nastcenc_image* astc_img_from_floatx4_array(\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -102,6 +102,12 @@ struct compression_workload {\nastcenc_error error;\n};\n+static bool ends_with(const std::string& str, const std::string& suffix)\n+{\n+ return (str.size() >= suffix.size()) &&\n+ (0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix));\n+}\n+\nstatic void compression_workload_runner(\nint thread_count,\nint thread_id,\n@@ -948,12 +954,40 @@ int main(\nastc_compressed_image image_comp {};\nif (operation & ASTCENC_STAGE_LD_COMP)\n{\n+ if (ends_with(input_filename, \".astc\"))\n+ {\n+ // TODO: Just pass on a std::string\nerror = load_cimage(input_filename.c_str(), image_comp);\nif (error)\n{\nreturn 1;\n}\n}\n+ else if (ends_with(input_filename, \".ktx\"))\n+ {\n+ // TODO: Just pass on a std::string\n+ bool is_srgb;\n+ error = load_ktx_compressed_image(input_filename.c_str(), is_srgb, image_comp);\n+ if (error)\n+ {\n+ return 1;\n+ }\n+\n+ if (is_srgb && (profile != ASTCENC_PRF_LDR_SRGB))\n+ {\n+ printf(\"WARNING: Input file is sRGB, but decompressing as linear\\n\");\n+ }\n+\n+ if (!is_srgb && (profile == ASTCENC_PRF_LDR_SRGB))\n+ {\n+ printf(\"WARNING: Input file is linear, but decompressing as sRGB\\n\");\n+ }\n+ }\n+ else\n+ {\n+ printf(\"ERROR: Unknown compressed input file type\\n\");\n+ }\n+ }\nastcenc_config config {};\nerror = init_astcenc_config(argc, argv, profile, operation, image_comp, config);\n@@ -1092,6 +1126,8 @@ int main(\n// Store compressed image\nif (operation & ASTCENC_STAGE_ST_COMP)\n+ {\n+ if (ends_with(output_filename, \".astc\"))\n{\nerror = store_cimage(image_comp, output_filename.c_str());\nif (error)\n@@ -1100,6 +1136,22 @@ int main(\nreturn 1;\n}\n}\n+ else if (ends_with(output_filename, \".ktx\"))\n+ {\n+ bool srgb = profile == ASTCENC_PRF_LDR_SRGB;\n+ error = store_ktx_compressed_image(image_comp, output_filename.c_str(), srgb);\n+ if (error)\n+ {\n+ printf (\"ERROR: Failed to store compressed image\\n\");\n+ return 1;\n+ }\n+ }\n+ else\n+ {\n+ printf(\"ERROR: Unknown compressed output file type\\n\");\n+ return 1;\n+ }\n+ }\n// Store decompressed image\nif (operation & ASTCENC_STAGE_ST_NCOMP)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -437,12 +437,14 @@ COMPRESSION FILE FORMATS\nThe following formats are supported as compression outputs:\nASTC (*.astc)\n+ Khronos Texture KTX (*.ktx)\nDECOMPRESSION FILE FORMATS\nThe following formats are supported as decompression inputs:\nASTC (*.astc)\n+ Khronos Texture KTX (*.ktx)\nThe following formats are supported as decompression outputs:\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -680,9 +680,9 @@ class CLIPTest(CLITestBase):\ncolOut = tli.Image(imOut).get_colors((7, 7))\nself.assertColorSame(colIn, colOut)\n- def test_valid_ldr_output_formats(self):\n+ def test_valid_uncomp_ldr_output_formats(self):\n\"\"\"\n- Test valid LDR output file formats.\n+ Test valid uncompressed LDR output file formats.\n\"\"\"\nimgFormats = [\"bmp\", \"dds\", \"ktx\", \"png\", \"tga\"]\n@@ -700,6 +700,30 @@ class CLIPTest(CLITestBase):\ncolOut = tli.Image(imOut).get_colors((7, 7))\nself.assertColorSame(colIn, colOut)\n+ def test_valid_comp_ldr_output_formats(self):\n+ \"\"\"\n+ Test valid compressed LDR output file formats.\n+ \"\"\"\n+ imgFormats = [\"astc\", \"ktx\"]\n+\n+ for imgFormat in imgFormats:\n+ with self.subTest(imgFormat=imgFormat):\n+ imIn = self.get_ref_image_path(\"LDR\", \"input\", \"A\")\n+ imOut = self.get_tmp_image_path(\"EXP\", \".%s\" % imgFormat)\n+ imOut2 = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+\n+ command = [self.binary, \"-cl\", imIn, imOut, \"4x4\", \"-fast\"]\n+ self.exec(command)\n+\n+ command = [self.binary, \"-dl\", imOut, imOut2]\n+ self.exec(command)\n+\n+ # Check colors if image wrapper supports it\n+ if tli.Image.is_format_supported(imgFormat):\n+ colIn = tli.Image(imIn).get_colors((7, 7))\n+ colOut = tli.Image(imOut2).get_colors((7, 7))\n+ self.assertColorSame(colIn, colOut2)\n+\ndef test_valid_hdr_input_formats(self):\n\"\"\"\nTest valid HDR input file formats.\n@@ -720,9 +744,9 @@ class CLIPTest(CLITestBase):\ncolOut = tli.Image(imOut).get_colors((7, 7))\nself.assertColorSame(colIn, colOut)\n- def test_valid_hdr_output_formats(self):\n+ def test_valid_uncomp_hdr_output_formats(self):\n\"\"\"\n- Test valid HDR output file formats.\n+ Test valid uncompressed HDR output file formats.\n\"\"\"\nimgFormats = [\"dds\", \"exr\", \"ktx\"]\n@@ -740,6 +764,30 @@ class CLIPTest(CLITestBase):\ncolOut = tli.Image(imOut).get_colors((7, 7))\nself.assertColorSame(colIn, colOut)\n+ def test_valid_comp_hdr_output_formats(self):\n+ \"\"\"\n+ Test valid compressed HDR output file formats.\n+ \"\"\"\n+ imgFormats = [\"astc\", \"ktx\"]\n+\n+ for imgFormat in imgFormats:\n+ with self.subTest(imgFormat=imgFormat):\n+ imIn = self.get_ref_image_path(\"HDR\", \"input\", \"A\")\n+ imOut = self.get_tmp_image_path(\"EXP\", \".%s\" % imgFormat)\n+ imOut2 = self.get_tmp_image_path(\"HDR\", \"decomp\")\n+\n+ command = [self.binary, \"-ch\", imIn, imOut, \"4x4\", \"-fast\"]\n+ self.exec(command)\n+\n+ command = [self.binary, \"-dh\", imOut, imOut2]\n+ self.exec(command)\n+\n+ # Check colors if image wrapper supports it\n+ if tli.Image.is_format_supported(imgFormat):\n+ colIn = tli.Image(imIn).get_colors((7, 7))\n+ colOut = tli.Image(imOut2).get_colors((7, 7))\n+ self.assertColorSame(colIn, colOut2)\n+\ndef test_compress_mask(self):\n\"\"\"\nTest compression of mask textures.\n@@ -1486,6 +1534,19 @@ class CLINTest(CLITestBase):\nself.exec(command)\n+ def test_cl_unknown_output(self):\n+ \"\"\"\n+ Test -cl with an unknown output file extension.\n+ \"\"\"\n+ # Build an otherwise valid command with the test flaw\n+ command = [\n+ self.binary, \"-cl\",\n+ self.get_ref_image_path(\"LDR\", \"input\", \"A\"),\n+ \"./test.aastc\",\n+ \"4x4\", \"-fast\"]\n+\n+ self.exec(command)\n+\ndef test_cl_bad_block_size(self):\n\"\"\"\nTest -cl with an invalid block size.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add KTX as a compressed file format option (#127) Only supports mip 0; there is no automatic mipmap generation at this point.
61,745
12.07.2020 20:19:48
-3,600
6424322e1018f8c38f78a127370903f815df5bcf
Use static library on Windows
[ { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-avx2.vcxproj", "new_path": "Source/VS2019/astcenc-avx2.vcxproj", "diff": "<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n<PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>\n<PrecompiledHeader>\n</PrecompiledHeader>\n<SubSystem>Console</SubSystem>\n<AdditionalDependencies>\n</AdditionalDependencies>\n- <StackReserveSize>4294967296</StackReserveSize>\n+ <StackReserveSize>8388608</StackReserveSize>\n</Link>\n</ItemDefinitionGroup>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n<PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>\n<FloatingPointModel>Precise</FloatingPointModel>\n<AdditionalDependencies>\n</AdditionalDependencies>\n<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\n- <StackReserveSize>4294967296</StackReserveSize>\n+ <StackReserveSize>8388608</StackReserveSize>\n</Link>\n</ItemDefinitionGroup>\n<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse2.vcxproj", "new_path": "Source/VS2019/astcenc-sse2.vcxproj", "diff": "<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n<PreprocessorDefinitions>WIN32;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<PrecompiledHeader>\n</PrecompiledHeader>\n<SubSystem>Console</SubSystem>\n<AdditionalDependencies>\n</AdditionalDependencies>\n- <StackReserveSize>4294967296</StackReserveSize>\n+ <StackReserveSize>8388608</StackReserveSize>\n</Link>\n</ItemDefinitionGroup>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n<PreprocessorDefinitions>WIN32;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<FloatingPointModel>Precise</FloatingPointModel>\n<AdditionalDependencies>\n</AdditionalDependencies>\n<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\n- <StackReserveSize>4294967296</StackReserveSize>\n+ <StackReserveSize>8388608</StackReserveSize>\n</Link>\n</ItemDefinitionGroup>\n<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "new_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "diff": "<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n<PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<PrecompiledHeader>\n</PrecompiledHeader>\n<SubSystem>Console</SubSystem>\n<AdditionalDependencies>\n</AdditionalDependencies>\n- <StackReserveSize>4294967296</StackReserveSize>\n+ <StackReserveSize>8388608</StackReserveSize>\n</Link>\n</ItemDefinitionGroup>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n<PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<FloatingPointModel>Precise</FloatingPointModel>\n<AdditionalDependencies>\n</AdditionalDependencies>\n<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\n- <StackReserveSize>4294967296</StackReserveSize>\n+ <StackReserveSize>8388608</StackReserveSize>\n</Link>\n</ItemDefinitionGroup>\n<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use static library on Windows
61,745
12.07.2020 20:18:47
-3,600
86104844ad220a31234ab91291d9dee4ec05c800
Fix compilation warnings in TinyEXR
[ { "change_type": "MODIFY", "old_path": "Source/tinyexr.h", "new_path": "Source/tinyexr.h", "diff": "@@ -7369,16 +7369,16 @@ static void WriteAttributeToMemory(std::vector<unsigned char> *out,\nout->insert(out->end(), data, data + len);\n}\n-typedef struct {\n+struct ChannelInfo {\nstd::string name; // less than 255 bytes long\nint pixel_type;\nint x_sampling;\nint y_sampling;\nunsigned char p_linear;\nunsigned char pad[3];\n-} ChannelInfo;\n+};\n-typedef struct {\n+struct HeaderInfo {\nstd::vector<tinyexr::ChannelInfo> channels;\nstd::vector<EXRAttribute> attributes;\n@@ -7430,7 +7430,7 @@ typedef struct {\nheader_len = 0;\ncompression_type = 0;\n}\n-} HeaderInfo;\n+};\nstatic bool ReadChannelInfo(std::vector<ChannelInfo> &channels,\nconst std::vector<unsigned char> &data) {\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix compilation warnings in TinyEXR
61,745
12.07.2020 20:28:14
-3,600
b7f3c35223003c1d147e1c632b59faf93c11411d
Enable -Werror on Windows builds
[ { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-avx2.vcxproj", "new_path": "Source/VS2019/astcenc-avx2.vcxproj", "diff": "<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<LanguageStandard>stdcpp14</LanguageStandard>\n+ <TreatWarningAsError>true</TreatWarningAsError>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<StringPooling>true</StringPooling>\n<LanguageStandard>stdcpp14</LanguageStandard>\n+ <TreatWarningAsError>true</TreatWarningAsError>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse2.vcxproj", "new_path": "Source/VS2019/astcenc-sse2.vcxproj", "diff": "<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<LanguageStandard>stdcpp14</LanguageStandard>\n+ <TreatWarningAsError>true</TreatWarningAsError>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<StringPooling>true</StringPooling>\n<LanguageStandard>stdcpp14</LanguageStandard>\n+ <TreatWarningAsError>true</TreatWarningAsError>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "new_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "diff": "<WarningLevel>Level3</WarningLevel>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<LanguageStandard>stdcpp14</LanguageStandard>\n+ <TreatWarningAsError>true</TreatWarningAsError>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\n<StringPooling>true</StringPooling>\n<LanguageStandard>stdcpp14</LanguageStandard>\n+ <TreatWarningAsError>true</TreatWarningAsError>\n</ClCompile>\n<Link>\n<GenerateDebugInformation>true</GenerateDebugInformation>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Enable -Werror on Windows builds
61,745
12.07.2020 22:27:48
-3,600
74f1fd88013039530bdfafd2b34b232a9e83bb4f
Write up codec API doxygen
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "*\n* This interface is the entry point to the core astcenc codec. It aims to be\n* easy to use for non-experts, but also to allow experts to have fine control\n- * over the compressor heuristics. The core codec only handles compression and\n- * decompression, transferring all inputs and outputs via memory buffers. To\n- * catch obvious input/output buffer sizing issues, which can cause security\n- * and stability problems, all transfer buffers are explicitly sized.\n+ * over the compressor heuristics if needed. The core codec only handles\n+ * compression and decompression, transferring all inputs and outputs via\n+ * memory buffers. To catch obvious input/output buffer sizing issues, which\n+ * can cause security and stability problems, all transfer buffers are\n+ * explicitly sized.\n*\n* While the aim is that we keep this interface mostly stable, it should be\n* viewed as a mutable interface tied to a specific source version. We are not\n* Multi-threading can be used two ways.\n*\n* * An application wishing to process multiple images in parallel can\n- * process allocate multiple contexts and assign each context to a thread.\n+ * allocate multiple contexts and assign each context to a thread.\n* * An application wishing to process a single image in using multiple\n* threads can configure the context for multi-threaded use, and invoke\n- * astcenc_compress() once per thread to for faster compression. The\n- * caller is responsible for creating the worker threads. Note that\n+ * astcenc_compress() once per thread for faster compression. The caller\n+ * is responsible for creating the worker threads. Note that\n* decompression is always single-threaded.\n*\n* When using multi-threading for a single image is is critical that all of the\n* specified threads call astcenc_compress(); the internal code synchronizes\n* using barriers that will wait forever if some threads are missing.\n*\n- * Manual threading\n- * ================\n+ * Threading\n+ * =========\n*\n* In pseudocode, the usage for manual user threading looks like this:\n*\n*\n* // Clean up\n* astcenc_context_free(my_context);\n+ *\n+ * Images\n+ * ======\n+ *\n+ * Images are passed in as a astcenc_image structure. Inputs can be either\n+ * 8-bit unorm inputs (passed in via the data8 pointer), or 16-bit floating\n+ * point inputs (passed in via the data16 pointer). The unused pointer should\n+ * be set to nullptr.\n+ *\n+ * Data is always passed in as 4 color channels, and accessed as 3D array\n+ * indexed using e.g.\n+ *\n+ * data8[z_coord][y_coord][x_coord * 4 ] // Red\n+ * data8[z_coord][y_coord][x_coord * 4 + 1] // Green\n+ * data8[z_coord][y_coord][x_coord * 4 + 2] // Blue\n+ * data8[z_coord][y_coord][x_coord * 4 + 3] // Alpha\n+ *\n+ * If a region-based error heuristic is used for compression, the image will\n+ * need to be padded on all sides by pad_dim texels in x and y dimensions (and\n+ * z dimensions for 3D images). The padding region must be filled by\n+ * extrapolating the nearest edge color. The required padding size is given by\n+ * the following config settings:\n+ *\n+ * max(config.v_rgba_radius, config.a_scale_radius)\n*/\n#ifndef ASTCENC_INCLUDED\n/* ============================================================================\nData declarations\n============================================================================ */\n+\n+/**\n+ * @brief An opaque structure; see astcenc_internal.h for definition.\n+ */\nstruct astcenc_context;\n-// Return codes\n+/**\n+ * @brief A codec API error code.\n+ */\nenum astcenc_error {\n+ /** @brief The call was successful. */\nASTCENC_SUCCESS = 0,\n+ /** @brief The call failed due to low memory. */\nASTCENC_ERR_OUT_OF_MEM,\n+ /** @brief The call failed due to the build using fast math. */\nASTCENC_ERR_BAD_CPU_FLOAT,\n+ /** @brief The call failed due to the build using an unsupported ISA. */\nASTCENC_ERR_BAD_CPU_ISA,\n+ /** @brief The call failed due to an out-of-spec parameter. */\nASTCENC_ERR_BAD_PARAM,\n+ /** @brief The call failed due to an out-of-spec block size. */\nASTCENC_ERR_BAD_BLOCK_SIZE,\n+ /** @brief The call failed due to an out-of-spec color profile. */\nASTCENC_ERR_BAD_PROFILE,\n+ /** @brief The call failed due to an out-of-spec quality preset. */\nASTCENC_ERR_BAD_PRESET,\n+ /** @brief The call failed due to an out-of-spec channel swizzle. */\nASTCENC_ERR_BAD_SWIZZLE,\n+ /** @brief The call failed due to an out-of-spec flag set. */\nASTCENC_ERR_BAD_FLAGS,\n+ /** @brief The call failed due to unimplemented functionality. */\nASTCENC_ERR_NOT_IMPLEMENTED\n};\n-// Compression color feature profile\n+/**\n+ * @brief A codec color profile.\n+ */\nenum astcenc_profile {\n+ /** @brief The LDR sRGB color profile. */\nASTCENC_PRF_LDR_SRGB = 0,\n+ /** @brief The LDR linear color profile. */\nASTCENC_PRF_LDR,\n+ /** @brief The HDR RGB with LDR alpha color profile. */\nASTCENC_PRF_HDR_RGB_LDR_A,\n+ /** @brief The HDR RGBA color profile. */\nASTCENC_PRF_HDR\n};\n-// Compression quality preset\n+/**\n+ * @brief A codec quality preset.\n+ */\nenum astcenc_preset {\n+ /** @brief The fast, lowest quality, search preset. */\nASTCENC_PRE_FAST = 0,\n+ /** @brief The medium quality search preset. */\nASTCENC_PRE_MEDIUM,\n+ /** @brief The throrough quality search preset. */\nASTCENC_PRE_THOROUGH,\n+ /** @brief The exhaustive quality search preset. */\nASTCENC_PRE_EXHAUSTIVE\n};\n-// Image channel data type\n-enum astcenc_type {\n- ASTCENC_TYP_U8 = 0,\n- ASTCENC_TYP_F16\n-};\n-\n-// Image channel swizzles\n+/**\n+ * @brief A codec channel swizzle selector.\n+ */\nenum astcenc_swz {\n+ /** @brief Select the red channel. */\nASTCENC_SWZ_R = 0,\n+ /** @brief Select the green channel. */\nASTCENC_SWZ_G = 1,\n+ /** @brief Select the blue channel. */\nASTCENC_SWZ_B = 2,\n+ /** @brief Select the alpha channel. */\nASTCENC_SWZ_A = 3,\n+ /** @brief Use a constant zero channel. */\nASTCENC_SWZ_0 = 4,\n+ /** @brief Use a constant one channel. */\nASTCENC_SWZ_1 = 5,\n+ /** @brief Use a reconstructed normal vector Z channel. */\nASTCENC_SWZ_Z = 6\n};\n-// Image channel swizzles\n+/**\n+ * @brief A texel channel swizzle.\n+ */\nstruct astcenc_swizzle {\n+ /** @brief The red channel selector. */\nastcenc_swz r;\n+ /** @brief The green channel selector. */\nastcenc_swz g;\n+ /** @brief The blue channel selector. */\nastcenc_swz b;\n+ /** @brief The alpha channel selector. */\nastcenc_swz a;\n};\n-// Config mode flags\n+/**\n+ * @brief Enable normal map compression.\n+ *\n+ * Input data will be treated a two channel normal map, storing X and Y, and\n+ * the codec will optimize for angular error rather than simple linear PSNR.\n+ * In this mode the input swizzle should be e.g. rrrg (the default ordering for\n+ * ASTC normals on the command line) or gggr (the ordering used by BC5).\n+ */\nstatic const unsigned int ASTCENC_FLG_MAP_NORMAL = 1 << 0;\n+\n+/**\n+ * @brief Enable mask map compression.\n+ *\n+ * Input data will be treated a multi-layer mask map, where is is desirable for\n+ * the color channels to be treated independently for the purposes of error\n+ * analysis.\n+ */\nstatic const unsigned int ASTCENC_FLG_MAP_MASK = 1 << 1;\n+\n+/**\n+ * @brief Enable alpha weighting.\n+ *\n+ * The input alpha value is used for transparency, so errors in the RGB\n+ * channels are weighted by the transparency level. This allows the codec to\n+ * more accurately encode the alpha value in areas where the color value\n+ * is less significant.\n+ */\nstatic const unsigned int ASTCENC_FLG_USE_ALPHA_WEIGHT = 1 << 2;\n+\n+/**\n+ * @brief Enable perceptual error metrics.\n+ *\n+ * This mode enables perceptual compression mode, which will optimize for\n+ * perceptual error rather than best PSNR. Only some input modes support\n+ * perceptual error metrics.\n+ */\nstatic const unsigned int ASTCENC_FLG_USE_PERCEPTUAL = 1 << 3;\n+/**\n+ * @brief The bit mask of all valid flags.\n+ */\nstatic const unsigned int ASTCENC_ALL_FLAGS =\nASTCENC_FLG_MAP_NORMAL |\nASTCENC_FLG_MAP_MASK |\nASTCENC_FLG_USE_ALPHA_WEIGHT |\nASTCENC_FLG_USE_PERCEPTUAL;\n-// Config structure\n+/**\n+ * @brief The config structure.\n+ *\n+ * This structure will initially be populated by a call to astcenc_init_config,\n+ * but power users may modify it before calling astcenc_context_alloc. See\n+ * astcenccli_toplevel_help.cpp for full user documentation of the power-user\n+ * settings.\n+ *\n+ * Note for any settings which are associated with a specific color channel,\n+ * the value in the config applies to the channel that exists after any\n+ * compression data swizzle is applied.\n+ */\nstruct astcenc_config {\n+ /** @brief The color profile. */\nastcenc_profile profile;\n+\n+ /** @brief The set of set flags. */\nunsigned int flags;\n+\n+ /** @brief The ASTC block size X dimension. */\nunsigned int block_x;\n+\n+ /** @brief The ASTC block size Y dimension. */\nunsigned int block_y;\n+\n+ /** @brief The ASTC block size Z dimension. */\nunsigned int block_z;\n+\n+ /** @brief The size of the texel kernel for error weighting (-v). */\nunsigned int v_rgba_radius;\n+\n+ /** @brief The mean and stdev channel mix for error weighting (-v). */\nfloat v_rgba_mean_stdev_mix;\n+\n+ /** @brief The texel RGB power for error weighting (-v). */\nfloat v_rgb_power;\n+\n+ /** @brief The texel RGB base weight for error weighting (-v). */\nfloat v_rgb_base;\n+\n+ /** @brief The texel RGB mean weight for error weighting (-v). */\nfloat v_rgb_mean;\n+\n+ /** @brief The texel RGB stdev for error weighting (-v). */\nfloat v_rgb_stdev;\n+\n+ /** @brief The texel A power for error weighting (-va). */\nfloat v_a_power;\n+\n+ /** @brief The texel A base weight for error weighting (-va). */\nfloat v_a_base;\n+\n+ /** @brief The texel A mean weight for error weighting (-va). */\nfloat v_a_mean;\n+\n+ /** @brief The texel A stdev for error weighting (-va). */\nfloat v_a_stdev;\n+\n+ /** @brief The red channel weight scale for error weighting (-cw). */\nfloat cw_r_weight;\n+\n+ /** @brief The green channel weight scale for error weighting (-cw). */\nfloat cw_g_weight;\n+\n+ /** @brief The blue channel weight scale for error weighting (-cw). */\nfloat cw_b_weight;\n+\n+ /** @brief The alpha channel weight scale for error weighting (-cw). */\nfloat cw_a_weight;\n+\n+ /**\n+ * @brief The radius for any alpha-weight scaling (-a).\n+ *\n+ * It is recommended that this is set to 1 when using FLG_USE_ALPHA_WEIGHT\n+ * on a texture that will be sampled using linear texture filtering to\n+ * minimize color bleed out of transparent texels that are adjcent to\n+ * non-transparent texels.\n+ */\nunsigned int a_scale_radius;\n+\n+ /**\n+ * @brief The additional weight for block edge texels (-b).\n+ *\n+ * This is generic tool for reducing artefacts visible on block changes.\n+ */\nfloat b_deblock_weight;\n+\n+ /**\n+ * @brief The maximum number of partitions searched (-partitionlimit).\n+ *\n+ * Valid values are between 1 and 1024.\n+ */\nunsigned int tune_partition_limit;\n+\n+ /**\n+ * @brief The maximum centile for block modes searched (-blockmodelimit).\n+ *\n+ * Valid values are between 1 and 100.\n+ */\nunsigned int tune_block_mode_limit;\n+\n+ /**\n+ * @brief The maximum iterative refinements applied (-refinementlimit).\n+ *\n+ * Valid values are between 1 and N; there is no technical upper limit\n+ * but little benefit is expected after N=4.\n+ */\nunsigned int tune_refinement_limit;\n+\n+ /**\n+ * @brief The dB threshold for stopping block search (-dblimit).\n+ *\n+ * This option is ineffective for HDR textures.\n+ */\nfloat tune_db_limit;\n+\n+ /**\n+ * @brief The threshold for skipping 3+ partitions (-partitionearlylimit).\n+ *\n+ * This option is ineffective for normal maps.\n+ */\nfloat tune_partition_early_out_limit;\n+\n+ /**\n+ * @brief The threshold for skipping 2 weight planess (-planecorlimit).\n+ *\n+ * This option is ineffective for normal maps.\n+ */\nfloat tune_two_plane_early_out_limit;\n};\n/**\n- * Structure to store an uncompressed 2D image, or a slice from a 3D image.\n+ * @brief An uncompressed 2D or 3D image.\n*\n- * @param dim_x The x dimension of the image, in texels.\n- * @param dim_y The y dimension of the image, in texels.\n- * @param dim_z The z dimension of the image, in texels.\n- * @param channels The number of color channels.\n+ * Inputs can be either 8-bit unorm inputs (passed in via the data8 pointer),\n+ * or 16-bit floating point inputs (passed in via the data16 pointer). The\n+ * unused pointer must be set to nullptr. Data is always passed in as 4 color\n+ * channels, and accessed as 3D array indexed using [Z][Y][(X * 4) + (0..3)].\n*/\nstruct astcenc_image {\n+ /** @brief The X dimension of the image, in texels. */\nunsigned int dim_x;\n+ /** @brief The Y dimension of the image, in texels. */\nunsigned int dim_y;\n+ /** @brief The X dimension of the image, in texels. */\nunsigned int dim_z;\n+ /** @brief The border padding dimensions, in texels. */\nunsigned int dim_pad;\n+ /** @brief The data if 8-bit unorm. */\nuint8_t ***data8;\n+ /** @brief The data if 16-bit float. */\nuint16_t ***data16;\n};\n@@ -206,15 +410,15 @@ struct astcenc_image {\n* Populate a codec config based on default settings.\n*\n* Power users can edit the returned config struct to apply manual fine tuning\n- * before creating the context.\n+ * before allocating the context.\n*\n- * @param profile The color profile.\n- * @param block_x The ASTC block size X dimension.\n- * @param block_y The ASTC block size Y dimension.\n- * @param block_z The ASTC block size Z dimension.\n- * @param preset The search quality preset.\n- * @param flags Any ASTCENC_FLG_* flag bits.\n- * @param[out] config The output config struct to populate.\n+ * @param profile Color profile.\n+ * @param block_x ASTC block size X dimension.\n+ * @param block_y ASTC block size Y dimension.\n+ * @param block_z ASTC block size Z dimension.\n+ * @param preset Search quality preset.\n+ * @param flags A valid set of ASTCENC_FLG_* flag bits.\n+ * @param[out] config Output config struct to populate.\n*\n* @return ASTCENC_SUCCESS on success, or an error if the inputs are invalid\n* either individually, or in combination.\n@@ -229,15 +433,15 @@ astcenc_error astcenc_init_config(\nastcenc_config& config);\n/**\n- * Allocate a new compressor context based on the settings in the config.\n+ * @brief Allocate a new codec context based on a config.\n*\n* This function allocates all of the memory resources and threads needed by\n- * the compressor. This can be slow, so it is recommended that contexts are\n- * reused to serially compress multiple images in order to amortize setup cost.\n+ * the codec. This can be slow, so it is recommended that contexts are reused\n+ * to serially compress or decompress multiple images to amortize setup cost.\n*\n- * @param[in] config The codec config.\n- * @param thread_count The thread count to configure for.\n- * @param[out] context Output location to store an opaque context pointer.\n+ * @param[in] config Codec config.\n+ * @param thread_count Thread count to configure for.\n+ * @param[out] context Location to store an opaque context pointer.\n*\n* @return ASTCENC_SUCCESS on success, or an error if context creation failed.\n*/\n@@ -247,15 +451,20 @@ astcenc_error astcenc_context_alloc(\nastcenc_context** context);\n/**\n- * Compress an image.\n+ * @brief Compress an image.\n+ *\n+ * A single context can only compress or decompress a single image at a time.\n+ *\n+ * For a context configured for multi-threading, all N threads must call this\n+ * function or it will never return due to use of barrier-style thread\n+ * synchronization.\n*\n- * @param[in,out] context The codec context.\n- * @param[in,out] image The input image.\n- * @param swizzle The encoding data swizzle.\n+ * @param context Codec context.\n+ * @param[in,out] image Input image.\n+ * @param swizzle Compression data swizzle.\n* @param[out] data_out Pointer to output data array.\n* @param data_len Length of the output data array.\n- * @param thread_index The thread index [0..N-1] of the calling thread.\n- * All N threads must call this function.\n+ * @param thread_index Thread index [0..N-1] of calling thread.\n*\n* @return ASTCENC_SUCCESS on success, or an error if compression failed.\n*/\n@@ -268,13 +477,13 @@ astcenc_error astcenc_compress_image(\nunsigned int thread_index);\n/**\n- * Decompress an image.\n+ * @brief Decompress an image.\n*\n- * @param[in,out] context The codec context.\n+ * @param context Codec context.\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 The output image.\n- * @param swizzle The decoding data swizzle.\n+ * @param[in,out] image_out Output image.\n+ * @param swizzle Decompression data swizzle.\n*\n* @return ASTCENC_SUCCESS on success, or an error if decompression failed.\n*/\n@@ -288,13 +497,13 @@ astcenc_error astcenc_decompress_image(\n/**\n* Free the compressor context.\n*\n- * @param[in,out] context The codec context.\n+ * @param context The codec context.\n*/\nvoid astcenc_context_free(\nastcenc_context* context);\n/**\n- * Utility to get a string for specific status code.\n+ * @brief Get a printable string for specific status code.\n*\n* @param status The status value.\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -217,7 +217,7 @@ ADVANCED COMPRESSION\nweight = 1 / (<base> + <mean> * mean^2 + <stdev> * stdev^2)\n- The <radius> argument specifies the pixel radius of the\n+ The <radius> argument specifies the texel radius of the\nneighborhood over which the average and standard deviation are\ncomputed.\n@@ -230,9 +230,9 @@ ADVANCED COMPRESSION\nthese two extremes do a linear mix of the two error values.\nThe <power> argument is a power used to raise the values of the\n- input pixels before computing average and standard deviation;\n+ input texels before computing average and standard deviation;\ne.g. a power of 0.5 causes the codec to take the square root\n- of every input pixel value.\n+ of every input texel value.\n-va <power> <base> <mean> <stdev>\nCompute the per-texel relative error weighting for the alpha\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Write up codec API doxygen
61,745
13.07.2020 20:58:58
-3,600
d725f6e422ea878683c04e465b00aa5472b07ebb
Remove "a" from ETC1 coding swizzle
[ { "change_type": "MODIFY", "old_path": "Docs/Encoding.md", "new_path": "Docs/Encoding.md", "diff": "@@ -103,13 +103,13 @@ use today.\n| BC1 | `rgba` <sup>1</sup> | `.rgba` | |\n| BC3 | `rgba` | `.rgba` | |\n| BC3nm | `gggr` | `.ag` | |\n-| BC4 | `rrr1` | `.r1` | |\n+| BC4 | `rrr1` | `.r` | |\n| BC5 | `rrrg` | `.ra` <sup>2</sup> | |\n| BC6 | `rgb1` | `.rgb` | HDR profile only |\n| BC7 | `rgba` | `.rgba` | |\n| EAC_R11 | `rrr1` | `.r` | |\n| EAC_RG11 | `rrrg` | `.ra` <sup>2</sup> | |\n-| ETC1 | `rgba` | `.rgba` | |\n+| ETC1 | `rgb1` | `.rgb` | |\n| ETC2 | `rgba` <sup>1</sup> | `.rgb` | |\n| ETC2+EAC | `rgba` | `.rgba` | |\n| ETC2+EAC | `rgba` | `.rgba` | |\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove "a" from ETC1 coding swizzle
61,745
13.07.2020 21:00:05
-3,600
7e066cf898f2a22d0c0811a6ae18beda9406de57
Add "a" read swizzle to ETC2
[ { "change_type": "MODIFY", "old_path": "Docs/Encoding.md", "new_path": "Docs/Encoding.md", "diff": "@@ -110,7 +110,7 @@ use today.\n| EAC_R11 | `rrr1` | `.r` | |\n| EAC_RG11 | `rrrg` | `.ra` <sup>2</sup> | |\n| ETC1 | `rgb1` | `.rgb` | |\n-| ETC2 | `rgba` <sup>1</sup> | `.rgb` | |\n+| ETC2 | `rgba` <sup>1</sup> | `.rgba` | |\n| ETC2+EAC | `rgba` | `.rgba` | |\n| ETC2+EAC | `rgba` | `.rgba` | |\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add "a" read swizzle to ETC2
61,745
14.07.2020 12:53:29
-3,600
b58054274d950b4e075a9aa1954cfc5398e4bfee
Allow RadianceHDR as decompressed output
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -160,6 +160,17 @@ static int store_bmp_image_with_stb(\nreturn (res == 0) ? -1 : 4;\n}\n+static int store_hdr_image_with_stb(\n+ const astcenc_image* img,\n+ const char* filename,\n+ int y_flip\n+) {\n+ float* buf = floatx4_array_from_astc_img(img, y_flip);\n+ int res = stbi_write_hdr(filename, img->dim_x, img->dim_y, 4, buf);\n+ delete[] buf;\n+ return (res == 0) ? -1 : 4;\n+}\n+\n/*********************************************************************\nNative Load and store of KTX and DDS file formats.\n@@ -2043,6 +2054,7 @@ static const struct\n{\".tga\", \".TGA\", \"Targa\", 8, store_tga_image_with_stb},\n// HDR formats\n{\".exr\", \".EXR\", \"OpenEXR\", 16, store_exr_image_with_tinyexr},\n+ {\".hdr\", \".HDR\", \"Radiance HDR\", 16, store_hdr_image_with_stb},\n// Container formats\n{\".dds\", \".DDS\", \"DirectDraw DDS\", -1, store_dds_uncompressed_image},\n{\".ktx\", \".KTX\", \"Khronos KTX\", -1, store_ktx_uncompressed_image}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -455,6 +455,7 @@ DECOMPRESSION FILE FORMATS\nHDR Formats:\nOpenEXR (*.exr)\n+ Radiance HDR (*.hdr)\nContainer Formats:\nKhronos Texture KTX (*.ktx)\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -748,7 +748,7 @@ class CLIPTest(CLITestBase):\n\"\"\"\nTest valid uncompressed HDR output file formats.\n\"\"\"\n- imgFormats = [\"dds\", \"exr\", \"ktx\"]\n+ imgFormats = [\"dds\", \"exr\", \"hdr\", \"ktx\"]\nfor imgFormat in imgFormats:\nwith self.subTest(imgFormat=imgFormat):\n@@ -1373,7 +1373,7 @@ class CLIPTest(CLITestBase):\n# RMSE should be the same\np1RMSE = sum(self.get_channel_rmse(inputFile, p1DecompFile))\n- p2RMSE = sum(self.get_channel_rmse(inputFile, p2DecompFile)))\n+ p2RMSE = sum(self.get_channel_rmse(inputFile, p2DecompFile))\nself.assertEqual(p1RMSE, p2RMSE)\nclass CLINTest(CLITestBase):\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Allow RadianceHDR as decompressed output
61,745
16.07.2020 22:44:26
-3,600
94b74af584a11884d47dc03c2a3a462be325fddc
Clean up directory name for test images
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image_dl.py", "new_path": "Test/astc_test_image_dl.py", "diff": "@@ -59,7 +59,7 @@ def retrieve_kodak_set():\ntestSet = \"Kodak\"\nfor i in range(1, 25):\nfle = \"ldr-rgb-kodak%02u.png\" % i\n- dst = os.path.join(TEST_IMAGE_DIR, \"Kodak_Images\", \"LDR-RGB\", fle)\n+ dst = os.path.join(TEST_IMAGE_DIR, \"Kodak\", \"LDR-RGB\", fle)\nsrc = \"http://r0k.us/graphics/kodak/kodak/kodim%02u.png\" % i\ndownload(testSet, i, src, dst)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Clean up directory name for test images
61,745
16.07.2020 22:45:56
-3,600
cb93cf726d9e2eef41c3b679ccb44bdd4bac0259
Make batchbuild should forward CXX and DBG
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -159,10 +159,10 @@ clean:\n@echo \"[Clean] Removing $(VEC) build outputs\"\nbatchbuild:\n- @+$(MAKE) -s VEC=nointrin\n- @+$(MAKE) -s VEC=sse2\n- @+$(MAKE) -s VEC=sse4.2\n- @+$(MAKE) -s VEC=avx2\n+ @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=nointrin\n+ @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=sse2\n+ @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=sse4.2\n+ @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=avx2\nbatchclean:\n@+$(MAKE) -s clean VEC=nointrin\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make batchbuild should forward CXX and DBG
61,745
16.07.2020 22:49:49
-3,600
5030ae517dfadd41eda53da18a3d1c334e720d6a
Alllocate scratch buffers when context allocated
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -489,6 +489,9 @@ astcenc_error astcenc_context_alloc(\nbsd = new block_size_descriptor;\ninit_block_size_descriptor(config.block_x, config.block_y, config.block_z, bsd);\nctx->bsd = bsd;\n+\n+ size_t worksize = sizeof(compress_symbolic_block_buffers) * thread_count;\n+ ctx->working_buffers = aligned_malloc<compress_symbolic_block_buffers>(worksize , 32);\n}\ncatch(const std::bad_alloc&)\n{\n@@ -509,18 +512,20 @@ astcenc_error astcenc_context_alloc(\n}\nvoid astcenc_context_free(\n- astcenc_context* context\n+ astcenc_context* ctx\n) {\n- if (context)\n+ if (ctx)\n{\n- term_block_size_descriptor(context->bsd);\n- delete context->bsd;\n- delete context;\n+ aligned_free<compress_symbolic_block_buffers>(ctx->working_buffers);\n+ term_block_size_descriptor(ctx->bsd);\n+ delete ctx->bsd;\n+ delete ctx;\n}\n}\nstatic void compress_image(\nastcenc_context& ctx,\n+ unsigned int thread_index,\nconst astcenc_image& image,\nastcenc_swizzle swizzle,\nuint8_t* buffer\n@@ -542,8 +547,8 @@ static void compress_image(\nint row_blocks = xblocks;\nint plane_blocks = xblocks * yblocks;\n- // Allocate temporary buffers. Large, so allocate on the heap\n- auto temp_buffers = aligned_malloc<compress_symbolic_block_buffers>(sizeof(compress_symbolic_block_buffers), 32);\n+ // Use preallocated scratch buffer\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@@ -577,8 +582,6 @@ static void compress_image(\nctx.manage_compress.complete_task_assignment(count);\n};\n-\n- aligned_free<compress_symbolic_block_buffers>(temp_buffers);\n}\nastcenc_error astcenc_compress_image(\n@@ -646,7 +649,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, 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" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -842,27 +842,6 @@ struct avg_var_args\nint work_memory_size;\n};\n-struct astcenc_context\n-{\n- astcenc_config config;\n- block_size_descriptor* bsd;\n- pixel_region_variance_args arg;\n- avg_var_args ag;\n- unsigned int thread_count;\n-\n- float deblock_weights[MAX_TEXELS_PER_BLOCK];\n-\n- ParallelManager manage_avg_var;\n- ParallelManager manage_compress;\n-\n- // Regional average-and-variance information, initialized by\n- // compute_averages_and_variances() only if the astc encoder\n- // is requested to do error weighting based on averages and variances.\n- float4 *input_averages;\n- float4 *input_variances;\n- float *input_alpha_averages;\n-};\n-\n/**\n* @brief Compute regional averages and variances in an image.\n*\n@@ -1146,6 +1125,30 @@ uint16_t unorm16_to_sf16(\nuint16_t lns_to_sf16(\nuint16_t p);\n+\n+struct astcenc_context\n+{\n+ astcenc_config config;\n+ block_size_descriptor* bsd;\n+ pixel_region_variance_args arg;\n+ avg_var_args ag;\n+ unsigned int thread_count;\n+\n+ float deblock_weights[MAX_TEXELS_PER_BLOCK];\n+\n+ compress_symbolic_block_buffers* working_buffers;\n+\n+ ParallelManager manage_avg_var;\n+ ParallelManager manage_compress;\n+\n+ // Regional average-and-variance information, initialized by\n+ // compute_averages_and_variances() only if the astc encoder\n+ // is requested to do error weighting based on averages and variances.\n+ float4 *input_averages;\n+ float4 *input_variances;\n+ float *input_alpha_averages;\n+};\n+\n/* ============================================================================\nPlatform-specific functions\n============================================================================ */\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Alllocate scratch buffers when context allocated
61,745
16.07.2020 23:22:26
-3,600
1a2a73a3de6c668354233ce5e7f4344323a54745
Add documentation on recommend channel swizzles
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "* the following config settings:\n*\n* max(config.v_rgba_radius, config.a_scale_radius)\n+ *\n+ * Common compressor usage\n+ * =======================\n+ *\n+ * One of the most important things for coding image quality is to align the\n+ * input data channel count with the ASTC color endpoint mode. This avoids\n+ * wasting bits encoding channels you don't need in the endpoint colors.\n+ *\n+ * | Input data | Encoding swizzle | Sampling swizzle |\n+ * | ---------- | ---------------- | ---------------- |\n+ * | 1 channel | RRR1 | .g |\n+ * | 2 channels | RRRG | .ga |\n+ * | 3 channels | RGB1 | .rgb |\n+ * | 4 channels | RGBA | .rgba |\n+ *\n+ * The 1 and 2 channel modes recommend sampling from \"g\" to recover the\n+ * luminance value as this provide best compatibility with ETC1. For ETC the\n+ * luminance data will be stored as RGB565 where the green channel has the\n+ * best quality. For ASTC any of the rgb channels can be used - the same data\n+ * will be returned for all three.\n+ *\n+ * When using the normal map compression mode ASTC will store normals as a two\n+ * channel X+Y map. Input images must contain unit-length normalized and should\n+ * be passed in using the RRRG swizzle. The Z component can be programatically\n+ * recovered in shader code, using knowledge that the vector is unit length.\n*/\n#ifndef ASTCENC_INCLUDED\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add documentation on recommend channel swizzles
61,745
18.07.2020 22:03:14
-3,600
c0e4c83f7d5c1b3d275ef3378c8a4df673b5fed7
Finalize 2.0 build types and Jenkins builds
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -11,6 +11,7 @@ Source/astcenc-*\nSource/astcenc-*\nSource/VS2019/*Release\nSource/VS2019/*Debug\n+Source/VS2019/*.exe\nTest/DocOut\nTest/Images/Kodak\nTest/Images/Scratch*\n" }, { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -34,21 +34,21 @@ msbuild astcenc.sln /p:Configuration=Release /p:Platform=x64\n## macOS and Linux\nBuilds for macOS and Linux use GCC or Clang and Make. They are tested using\n-Clang 9.0, GCC 7.4, and Make 3.82. Using Clang 9.0 is recommended, as Clang\n-builds out-perform GCC builds by approximately 20% in benchmarked test runs.\n+Clang 9.0, GCC 7.4, and Make 3.82. Using Clang 9.0 is recommended, as it\n+out-performs GCC by 15-20% in benchmarked test runs.\n### Single variants\nTo compile a single SIMD variant compile with:\n```\n-make -C Source CXX=clang++ VEC=[nointrin|sse2|sse4.2|avx2] -j8\n+make -C Source CXX=clang++ VEC=[sse2|sse4.2|avx2] -j8\n```\n... and use:\n```\n-make -C Source CXX=clang++ VEC=[nointrin|sse2|sse4.2|avx2] clean\n+make -C Source CXX=clang++ VEC=[sse2|sse4.2|avx2] clean\n```\n... to clean the build.\n@@ -69,3 +69,14 @@ make -sC Source batchclean -j8\n... to clean the build.\n+### Developer build options\n+\n+The default build, `BUILD=release`, is heavily optimized using link-time\n+optimization (`-O3 -flto`) and does not include symbols.\n+\n+For debugging, add `BUILD=debug` to the Make command line. This will build a\n+non-optimized build (`-O0`) with symbols included (`-g`).\n+\n+For easier profiling, add `BUILD=profile` to the Make command line. This will\n+build a moderately optimized build (`-O2`) with symbols include (`-g`), but\n+without link-time optimization (no `-flto`).\n" }, { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "# under the License.\n# -----------------------------------------------------------------------------\n-# Configure the vectorization intrinsics support; valid values are:\n+# Configure the SIMD ISA and intrinsics support; valid values are:\n#\n-# * nointrin - allow use of sse2 by the compiler, but no manual instrinsics\n# * sse2 - allow use of sse2\n# * sse4.2 - allow use of sse4.2 and popcnt\n# * avx2 - allow use of avx2, sse4.2, and popcnt\n#\n-# Note that we always enable at least sse2 support for compiler generated code,\n-# as it is guaranteed to be present in x86-64, we only allow disabling of our\n-# manually written instrinsic functions.\n-#\n-# Also note that we currently assume that sse4.2 implies support for popcnt,\n-# which is the default GCC behavior and true on currently shipping hardware.\n+# We assume that sse4.2 implies support for popcnt, which is the default GCC\n+# behavior and true on currently shipping hardware.\nVEC ?= avx2\n-DBG?=0\n+# Configure the build type; valid values are:\n+#\n+# * release - build a fully optimized build without symbols\n+# * profile - build a moderately optimized build, with symbols\n+# * debug - build an unoptimized build with symbols\n+BUILD ?= release\nSOURCES = \\\nastcenc_averages_and_directions.cpp \\\n@@ -87,17 +87,22 @@ BINARY = astcenc-$(VEC)\nCXXFLAGS = -std=c++14 -fvisibility=hidden -mfpmath=sse \\\n-Wall -Wextra -Wpedantic -Werror -Werror=shadow -Wdouble-promotion\n-# Validate that the DBG parameter is a supported value, and patch CXXFLAGS\n-ifeq ($(DBG),0)\n+# Validate that the BUILD parameter is a supported value, and patch CXXFLAGS\n+ifeq ($(BUILD),release)\nCXXFLAGS += -O3 -DNDEBUG -flto\nelse\n+ifeq ($(BUILD),profile)\n+CXXFLAGS += -O2 -g\n+else\n+ifeq ($(BUILD),debug)\nCXXFLAGS += -O0 -g\n+else\n+$(error Unsupported build, use BUILD=release/profile/debug)\n+endif\n+endif\nendif\n# Validate that the VEC parameter is a supported value, and patch CXXFLAGS\n-ifeq ($(VEC),nointrin)\n-CXXFLAGS += -msse2 -DASTCENC_SSE=0 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0\n-else\nifeq ($(VEC),sse2)\nCXXFLAGS += -msse2 -DASTCENC_SSE=20 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0\nelse\n@@ -107,8 +112,7 @@ else\nifeq ($(VEC),avx2)\nCXXFLAGS += -mavx2 -mpopcnt -DASTCENC_SSE=42 -DASTCENC_AVX=2 -DASTCENC_POPCNT=1\nelse\n-$(error Unsupported VEC target, use VEC=nointrin/sse2/sse4.2/avx2)\n-endif\n+$(error Unsupported VEC target, use VEC=sse2/sse4.2/avx2)\nendif\nendif\nendif\n@@ -120,11 +124,16 @@ CXXFLAGS_EXTERNAL = \\\n-Wno-double-promotion \\\n-fno-strict-aliasing\n+# ==================================================\n+# Exports for child make invocations\n+export CXX\n+export BUILD\n+\n# ==================================================\n# Build rules for the command line wrapper\n$(BINARY): $(EXTERNAL_OBJECTS) $(OBJECTS)\n@$(CXX) -o $@ $^ $(CXXFLAGS) -lpthread\n- @echo \"[Link] $@ (using $(VEC), debug=$(DBG))\"\n+ @echo \"[Link] $@ (using $(VEC) $(BUILD))\"\n# Note: ensure NDEBUG is undefined; all three libraries are weak at runtime\n# handling of corrupt files, relying on asserts to handle bd file input.\n@@ -159,13 +168,11 @@ clean:\n@echo \"[Clean] Removing $(VEC) build outputs\"\nbatchbuild:\n- @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=nointrin\n- @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=sse2\n- @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=sse4.2\n- @+$(MAKE) -s CXX=$(CXX) DBG=$(DBG) VEC=avx2\n+ @+$(MAKE) -s VEC=sse2\n+ @+$(MAKE) -s VEC=sse4.2\n+ @+$(MAKE) -s VEC=avx2\nbatchclean:\n- @+$(MAKE) -s clean VEC=nointrin\n@+$(MAKE) -s clean VEC=sse2\n@+$(MAKE) -s clean VEC=sse4.2\n@+$(MAKE) -s clean VEC=avx2\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-avx2.vcxproj", "new_path": "Source/VS2019/astcenc-avx2.vcxproj", "diff": "</AdditionalDependencies>\n<StackReserveSize>8388608</StackReserveSize>\n</Link>\n+ <PostBuildEvent>\n+ <Command>\n+ </Command>\n+ </PostBuildEvent>\n</ItemDefinitionGroup>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\n<StackReserveSize>8388608</StackReserveSize>\n</Link>\n+ <PostBuildEvent>\n+ <Command>copy /Y \"$(TargetDir)$(ProjectName).exe\" \"$(SolutionDir)$(ProjectName).exe\"</Command>\n+ </PostBuildEvent>\n</ItemDefinitionGroup>\n<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n<ImportGroup Label=\"ExtensionTargets\">\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse2.vcxproj", "new_path": "Source/VS2019/astcenc-sse2.vcxproj", "diff": "<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\n<StackReserveSize>8388608</StackReserveSize>\n</Link>\n+ <PostBuildEvent>\n+ <Command>copy /Y \"$(TargetDir)$(ProjectName).exe\" \"$(SolutionDir)$(ProjectName).exe\"</Command>\n+ </PostBuildEvent>\n</ItemDefinitionGroup>\n<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n<ImportGroup Label=\"ExtensionTargets\">\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "new_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "diff": "<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>\n<StackReserveSize>8388608</StackReserveSize>\n</Link>\n+ <PostBuildEvent>\n+ <Command>copy /Y \"$(TargetDir)$(ProjectName).exe\" \"$(SolutionDir)$(ProjectName).exe\"</Command>\n+ </PostBuildEvent>\n</ItemDefinitionGroup>\n<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n<ImportGroup Label=\"ExtensionTargets\">\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -469,10 +469,8 @@ void astcenc_print_header()\nconst char* simdtype = \"avx2\";\n#elif (ASTCENC_SSE == 42)\nconst char* simdtype = \"sse4.2\";\n-#elif (ASTCENC_SSE == 20)\n- const char* simdtype = \"sse2\";\n#else\n- const char* simdtype = \"unknown\";\n+ const char* simdtype = \"sse2\";\n#endif\n#if (ASTCENC_POPCNT == 1)\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -283,7 +283,7 @@ def parse_command_line():\nparser = argparse.ArgumentParser()\nrefcoders = [\"ref-1.7\", \"ref-2.0\", \"ref-prototype\"]\n- testcoders = [\"nointrin\", \"sse2\", \"sse4.2\", \"avx2\"]\n+ testcoders = [\"sse2\", \"sse4.2\", \"avx2\"]\ncoders = refcoders + testcoders + [\"all\"]\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=coders, help=\"test encoder variant\")\n" }, { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -34,7 +34,6 @@ pipeline {\nmake CXX=clang++ VEC=avx2\nmake CXX=clang++ VEC=sse4.2\nmake CXX=clang++ VEC=sse2\n- make CXX=clang++ VEC=nointrin\n'''\n}\n}\n@@ -70,6 +69,8 @@ pipeline {\nbat '''\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\ncall msbuild .\\\\Source\\\\VS2019\\\\astcenc-avx2.vcxproj /p:Configuration=Release /p:Platform=x64\n+ call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse4.2.vcxproj /p:Configuration=Release /p:Platform=x64\n+ call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse2.vcxproj /p:Configuration=Release /p:Platform=x64\n'''\n}\n}\n@@ -78,13 +79,15 @@ pipeline {\nbat '''\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\ncall msbuild .\\\\Source\\\\VS2019\\\\astcenc-avx2.vcxproj /p:Configuration=Debug /p:Platform=x64\n+ call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse4.2.vcxproj /p:Configuration=Debug /p:Platform=x64\n+ call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse2.vcxproj /p:Configuration=Debug /p:Platform=x64\n'''\n}\n}\nstage('Stash') {\nsteps {\n- dir('Source\\\\VS2019\\\\astcenc-avx2-Release') {\n- stash name: 'astcenc-win-release', includes: 'astcenc-avx2.exe'\n+ dir('Source\\\\VS2019\\\\') {\n+ stash name: 'astcenc-win-release', includes: '*.exe'\n}\n}\n}\n@@ -115,6 +118,8 @@ pipeline {\nsteps {\nsh '''\ncd ./Source/\n+ make VEC=avx2\n+ make VEC=sse4.2\nmake VEC=sse2\n'''\n}\n@@ -130,7 +135,7 @@ pipeline {\nsteps {\nsh '''\nexport PATH=/usr/local/bin:$PATH\n- python3 ./Test/astc_test_image.py --test-set Small --encoder=sse2\n+ python3 ./Test/astc_test_image.py --test-set Small\n'''\n//perfReport(sourceDataFiles:'TestOutput/results.xml')\n//junit(testResults: 'TestOutput/results.xml')\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Finalize 2.0 build types and Jenkins builds
61,745
18.07.2020 22:45:11
-3,600
8e5f09a5850630bb8c98c434d5bbf3d96b35e926
Don't use CLI header from core codec.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "* This module contains functions for querying the host extended ISA support.\n*/\n-#include \"astcenccli_internal.h\"\n+#include \"astcenc_internal.h\"\nstatic int g_cpu_has_sse42 = -1;\nstatic int g_cpu_has_avx2 = -1;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Don't use CLI header from core codec.
61,745
18.07.2020 22:58:55
-3,600
26ceed42f593dea62b23f3c9db9f6c97ee058b53
Added image clarifications to API header
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "* point inputs (passed in via the data16 pointer). The unused pointer should\n* be set to nullptr.\n*\n+ * Images can be any dimension; there is no requirement for them to be a\n+ * multiple of the ASTC block size.\n+ *\n* Data is always passed in as 4 color channels, and accessed as 3D array\n* indexed using e.g.\n*\n* data8[z_coord][y_coord][x_coord * 4 + 2] // Blue\n* data8[z_coord][y_coord][x_coord * 4 + 3] // Alpha\n*\n- * If a region-based error heuristic is used for compression, the image will\n- * need to be padded on all sides by pad_dim texels in x and y dimensions (and\n- * z dimensions for 3D images). The padding region must be filled by\n+ * If a region-based error heuristic is used for compression, the input image\n+ * must be padded on all sides by pad_dim texels in x and y dimensions (and z\n+ * dimensions for 3D images). The padding region must be filled by\n* extrapolating the nearest edge color. The required padding size is given by\n* the following config settings:\n*\n* max(config.v_rgba_radius, config.a_scale_radius)\n*\n+ * This can be programatically determined by reading the config containing the\n+ * values passed into astcenc_context_alloc().\n+ *\n* Common compressor usage\n* =======================\n*\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Added image clarifications to API header
61,745
18.07.2020 23:02:08
-3,600
e16ec01a7433bb3efabf8c01dbc6bb3eea6d9835
Standardize on noun_verb for API function names
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "*\n* // Configure the compressor run\n* astcenc_config my_config;\n- * astcenc_init_config(..., &my_config);\n+ * astcenc_config_init(..., &my_config);\n*\n* // Power users can tune the tweak <my_config> settings here ...\n*\n@@ -284,7 +284,7 @@ static const unsigned int ASTCENC_ALL_FLAGS =\n/**\n* @brief The config structure.\n*\n- * This structure will initially be populated by a call to astcenc_init_config,\n+ * This structure will initially be populated by a call to astcenc_config_init,\n* but power users may modify it before calling astcenc_context_alloc. See\n* astcenccli_toplevel_help.cpp for full user documentation of the power-user\n* settings.\n@@ -452,7 +452,7 @@ struct astcenc_image {\n* @return ASTCENC_SUCCESS on success, or an error if the inputs are invalid\n* either individually, or in combination.\n*/\n-astcenc_error astcenc_init_config(\n+astcenc_error astcenc_config_init(\nastcenc_profile profile,\nunsigned int block_x,\nunsigned int block_y,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -256,7 +256,7 @@ static astcenc_error validate_config(\nreturn ASTCENC_SUCCESS;\n}\n-astcenc_error astcenc_init_config(\n+astcenc_error astcenc_config_init(\nastcenc_profile profile,\nunsigned int block_x,\nunsigned int block_y,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -435,7 +435,7 @@ int init_astcenc_config(\nargidx ++;\n}\n- astcenc_error status = astcenc_init_config(profile, block_x, block_y, block_z, preset, flags, config);\n+ astcenc_error status = astcenc_config_init(profile, block_x, block_y, block_z, preset, flags, config);\nif (status == ASTCENC_ERR_BAD_BLOCK_SIZE)\n{\nprintf(\"ERROR: Block size '%s' is invalid\\n\", argv[4]);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Standardize on noun_verb for API function names
61,745
18.07.2020 23:14:01
-3,600
4e65e0278e16c81036b411741ab1d5f8d9a49f07
Don't use worker threads for -j 1 runs.
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1074,7 +1074,18 @@ int main(\nwork.data_len = buffer_size;\nwork.error = ASTCENC_SUCCESS;\n+ // Only launch worker threads for multi-threaded use - it makes basic\n+ // single-threaded profiling and debugging a little less convoluted\n+ if (cli_config.thread_count > 1)\n+ {\nlaunch_threads(cli_config.thread_count, compression_workload_runner, &work);\n+ }\n+ else\n+ {\n+ work.error = astcenc_compress_image(\n+ work.context, *work.image, work.swizzle,\n+ work.data_out, work.data_len, 0);\n+ }\nif (work.error != ASTCENC_SUCCESS)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Don't use worker threads for -j 1 runs.
61,745
19.07.2020 15:35:33
-3,600
42f552e50eaa0feebb09dbafeea8118cafb5f82c
Add support for decompression-only contexts
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -150,7 +150,7 @@ struct astcenc_context;\nenum astcenc_error {\n/** @brief The call was successful. */\nASTCENC_SUCCESS = 0,\n- /** @brief The call failed due to low memory. */\n+ /** @brief The call failed due to low memory, or undersized I/O buffers. */\nASTCENC_ERR_OUT_OF_MEM,\n/** @brief The call failed due to the build using fast math. */\nASTCENC_ERR_BAD_CPU_FLOAT,\n@@ -168,6 +168,8 @@ enum astcenc_error {\nASTCENC_ERR_BAD_SWIZZLE,\n/** @brief The call failed due to an out-of-spec flag set. */\nASTCENC_ERR_BAD_FLAGS,\n+ /** @brief The call failed due to the context not supporting the operation. */\n+ ASTCENC_ERR_BAD_CONTEXT,\n/** @brief The call failed due to unimplemented functionality. */\nASTCENC_ERR_NOT_IMPLEMENTED\n};\n@@ -272,6 +274,14 @@ static const unsigned int ASTCENC_FLG_USE_ALPHA_WEIGHT = 1 << 2;\n*/\nstatic const unsigned int ASTCENC_FLG_USE_PERCEPTUAL = 1 << 3;\n+/**\n+ * @brief Create a decompression-only context.\n+ *\n+ * This mode enables context allocation to skip some transient buffer\n+ * allocation, resulting in a lower-memory footprint.\n+ */\n+static const unsigned int ASTCENC_FLG_DECOMPRESS_ONLY = 1 << 4;\n+\n/**\n* @brief The bit mask of all valid flags.\n*/\n@@ -279,7 +289,8 @@ static const unsigned int ASTCENC_ALL_FLAGS =\nASTCENC_FLG_MAP_NORMAL |\nASTCENC_FLG_MAP_MASK |\nASTCENC_FLG_USE_ALPHA_WEIGHT |\n- ASTCENC_FLG_USE_PERCEPTUAL;\n+ ASTCENC_FLG_USE_PERCEPTUAL |\n+ ASTCENC_FLG_DECOMPRESS_ONLY;\n/**\n* @brief The config structure.\n@@ -468,8 +479,14 @@ astcenc_error astcenc_config_init(\n* the codec. This can be slow, so it is recommended that contexts are reused\n* to serially compress or decompress multiple images to amortize setup cost.\n*\n+ * Contexts can be allocated to support only decompression by setting the\n+ * ASTCENC_FLG_DECOMPRESS_ONLY flag when creating the configuration. These\n+ * contexts must be allocated with a thread count of 1 (decompression is always\n+ * single threaded), and the compression functions will fail if invoked.\n+ *\n* @param[in] config Codec config.\n- * @param thread_count Thread count to configure for.\n+ * @param thread_count Thread count to configure for. Decompress-only\n+ * contexts must have a thread_count of 1.\n* @param[out] context Location to store an opaque context pointer.\n*\n* @return ASTCENC_SUCCESS on success, or an error if context creation failed.\n@@ -514,8 +531,10 @@ astcenc_error astcenc_compress_image(\n* it for image N + 1.\n*\n* @param context Codec context.\n+ *\n+ * @return ASTCENC_SUCCESS on success, or an error if reset failed.\n*/\n-void astcenc_compress_reset(\n+astcenc_error astcenc_compress_reset(\nastcenc_context* context);\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -195,7 +195,8 @@ static astcenc_error validate_decompression_swizzle(\n* make no sense algorithmically will return an error.\n*/\nstatic astcenc_error validate_config(\n- astcenc_config &config\n+ astcenc_config &config,\n+ unsigned int thread_count\n) {\nastcenc_error status;\n@@ -217,6 +218,12 @@ static astcenc_error validate_config(\nreturn status;\n}\n+ // Decompress-only contexts must be single threaded\n+ if ((config.flags & ASTCENC_FLG_DECOMPRESS_ONLY) && (thread_count > 1))\n+ {\n+ return ASTCENC_ERR_BAD_PARAM;\n+ }\n+\nconfig.v_rgba_mean_stdev_mix = MAX(config.v_rgba_mean_stdev_mix, 0.0f);\nconfig.v_rgb_power = MAX(config.v_rgb_power, 0.0f);\nconfig.v_rgb_base = MAX(config.v_rgb_base, 0.0f);\n@@ -458,21 +465,28 @@ astcenc_error astcenc_context_alloc(\nctx = new astcenc_context;\nctx->thread_count = thread_count;\nctx->config = config;\n+ ctx->working_buffers = nullptr;\n- // Clear scratch storage (allocated per compress pass)\n+ // Clear scratch storage (allocated per compress, based on image size)\nctx->input_averages = nullptr;\nctx->input_variances = nullptr;\nctx->input_alpha_averages = nullptr;\n- // Copy the config first and validate the copy (may modify it)\n- status = validate_config(ctx->config);\n+ // Copy the config first and validate the copy (we may modify it)\n+ status = validate_config(ctx->config, thread_count);\nif (status != ASTCENC_SUCCESS)\n{\ndelete ctx;\nreturn status;\n}\n- // Rewrite config settings into a canonical internal form\n+ bsd = new block_size_descriptor;\n+ init_block_size_descriptor(config.block_x, config.block_y, config.block_z, bsd);\n+ ctx->bsd = bsd;\n+\n+ // Do setup only needed by compression\n+ if (!(status & ASTCENC_FLG_DECOMPRESS_ONLY))\n+ {\n// Expand deblock supression into a weight scale per texel in the block\nexpand_deblock_weights(*ctx);\n@@ -486,13 +500,10 @@ astcenc_error astcenc_context_alloc(\nctx->config.tune_db_limit = 0.0f;\n}\n- bsd = new block_size_descriptor;\n- init_block_size_descriptor(config.block_x, config.block_y, config.block_z, bsd);\n- ctx->bsd = bsd;\n-\nsize_t worksize = sizeof(compress_symbolic_block_buffers) * thread_count;\nctx->working_buffers = aligned_malloc<compress_symbolic_block_buffers>(worksize , 32);\n}\n+ }\ncatch(const std::bad_alloc&)\n{\nterm_block_size_descriptor(bsd);\n@@ -594,6 +605,11 @@ astcenc_error astcenc_compress_image(\n) {\nastcenc_error status;\n+ if (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY)\n+ {\n+ return ASTCENC_ERR_BAD_CONTEXT;\n+ }\n+\nstatus = validate_compression_swizzle(swizzle);\nif (status != ASTCENC_SUCCESS)\n{\n@@ -671,11 +687,17 @@ astcenc_error astcenc_compress_image(\nreturn ASTCENC_SUCCESS;\n}\n-void astcenc_compress_reset(\n+astcenc_error astcenc_compress_reset(\nastcenc_context* ctx\n) {\n+ if (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY)\n+ {\n+ return ASTCENC_ERR_BAD_CONTEXT;\n+ }\n+\nctx->manage_avg_var.reset();\nctx->manage_compress.reset();\n+ return ASTCENC_SUCCESS;\n}\nastcenc_error astcenc_decompress_image(\n@@ -756,6 +778,8 @@ const char* astcenc_get_error_string(\nreturn \"ASTCENC_ERR_BAD_FLAGS\";\ncase ASTCENC_ERR_BAD_SWIZZLE:\nreturn \"ASTCENC_ERR_BAD_SWIZZLE\";\n+ case ASTCENC_ERR_BAD_CONTEXT:\n+ return \"ASTCENC_ERR_BAD_CONTEXT\";\ncase ASTCENC_ERR_NOT_IMPLEMENTED:\nreturn \"ASTCENC_ERR_NOT_IMPLEMENTED\";\ndefault:\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1116,7 +1116,6 @@ int main(\nimage_decomp_out = alloc_image(\nout_bitness, image_comp.dim_x, image_comp.dim_y, image_comp.dim_z, 0);\n- // TODO: Pass through data len to avoid out-of-bounds reads\ncodec_status = astcenc_decompress_image(codec_context, image_comp.data, image_comp.data_len,\n*image_decomp_out, cli_config.swz_decode);\nif (codec_status != ASTCENC_SUCCESS)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add support for decompression-only contexts
61,745
21.07.2020 08:39:46
-3,600
e0ed7be3b2fe36bbfb402adc6bec22fdae0c714c
Support Arm arch64 builds Fixes
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -28,9 +28,10 @@ APP ?= astcenc\n# Configure the SIMD ISA and intrinsics support; valid values are:\n#\n-# * sse2 - allow use of sse2\n-# * sse4.2 - allow use of sse4.2 and popcnt\n-# * avx2 - allow use of avx2, sse4.2, and popcnt\n+# * neon - compile for Arm aarch64 + NEON\n+# * sse2 - allow use of x86-64 + sse2\n+# * sse4.2 - allow use of x86-64 + sse4.2 and popcnt\n+# * avx2 - allow use of x86-64 + avx2, sse4.2, and popcnt\nVEC ?= avx2\n# Configure the build type; valid values are:\n@@ -98,7 +99,7 @@ EXTERNAL_OBJECTS = $(EXTERNAL_SOURCES:.h=-$(BINARY).o)\n# ==================================================\n# CXXFLAGS setup (and input validation)\n-CXXFLAGS = -std=c++14 -fvisibility=hidden -mfpmath=sse \\\n+CXXFLAGS = -std=c++14 -fvisibility=hidden \\\n-Wall -Wextra -Wpedantic -Werror -Werror=shadow -Wdouble-promotion\n# Validate that the APP parameter is a supported value, and patch CXXFLAGS\n@@ -128,16 +129,21 @@ endif\nendif\n# Validate that the VEC parameter is a supported value, and patch CXXFLAGS\n+ifeq ($(VEC),neon)\n+# NEON is on by default; no enabled needed\n+CXXFLAGS += -DASTCENC_SSE=0 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0 -DASTCENC_VECALIGN=16\n+else\nifeq ($(VEC),sse2)\n-CXXFLAGS += -msse2 -DASTCENC_SSE=20 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0\n+CXXFLAGS += -mfpmath=sse -msse2 -DASTCENC_SSE=20 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0 -DASTCENC_VECALIGN=16\nelse\nifeq ($(VEC),sse4.2)\n-CXXFLAGS += -msse4.2 -mpopcnt -DASTCENC_SSE=42 -DASTCENC_AVX=0 -DASTCENC_POPCNT=1\n+CXXFLAGS += -mfpmath=sse -msse4.2 -mpopcnt -DASTCENC_SSE=42 -DASTCENC_AVX=0 -DASTCENC_POPCNT=1 -DASTCENC_VECALIGN=16\nelse\nifeq ($(VEC),avx2)\n-CXXFLAGS += -mavx2 -mpopcnt -DASTCENC_SSE=42 -DASTCENC_AVX=2 -DASTCENC_POPCNT=1\n+CXXFLAGS += -mfpmath=sse -mavx2 -mpopcnt -DASTCENC_SSE=42 -DASTCENC_AVX=2 -DASTCENC_POPCNT=1 -DASTCENC_VECALIGN=32\nelse\n-$(error Unsupported VEC target, use VEC=sse2/sse4.2/avx2)\n+$(error Unsupported VEC target, use VEC=neon/sse2/sse4.2/avx2)\n+endif\nendif\nendif\nendif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1003,7 +1003,7 @@ struct encoding_choice_errors\n};\n// buffers used to store intermediate data in compress_symbolic_block_fixed_partition_*()\n-struct alignas(32) compress_fixed_partition_buffers\n+struct alignas(ASTCENC_VECALIGN) compress_fixed_partition_buffers\n{\nendpoints_and_weights ei1;\nendpoints_and_weights ei2;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "// under the License.\n// ----------------------------------------------------------------------------\n+#if (ASTCENC_SSE > 0) || (ASTCENC_AVX > 0) || (ASTCENC_POPCNT > 0)\n+\n/**\n* @brief Platform-specific function implementations.\n*\n@@ -94,3 +96,5 @@ int cpu_supports_avx2()\nreturn g_cpu_has_avx2;\n}\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -330,15 +330,15 @@ void compute_angular_endpoints_for_quantization_levels(\nint max_quantization_steps = quantization_steps_for_level[max_quantization_level + 1];\n- alignas(32) float angular_offsets[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) float angular_offsets[ANGULAR_STEPS];\nint max_angular_steps = max_angular_steps_needed_for_quant_level[max_quantization_level];\ncompute_angular_offsets(samplecount, samples, sample_weights, max_angular_steps, angular_offsets);\n- alignas(32) int32_t lowest_weight[ANGULAR_STEPS];\n- alignas(32) int32_t weight_span[ANGULAR_STEPS];\n- alignas(32) float error[ANGULAR_STEPS];\n- alignas(32) float cut_low_weight_error[ANGULAR_STEPS];\n- alignas(32) float cut_high_weight_error[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) int32_t lowest_weight[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) int32_t weight_span[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) float error[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) float cut_low_weight_error[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) float cut_high_weight_error[ANGULAR_STEPS];\ncompute_lowest_and_highest_weight(samplecount, samples, sample_weights,\nmax_angular_steps, max_quantization_steps,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Support Arm arch64 builds Fixes #137
61,745
21.07.2020 09:05:52
-3,600
aaab148f6156df647469f6b76fee0b95f11eddd8
Remove exceptions from core library Note that stdlib can still throw them, as we are e.g. not using new(nothrow).
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -200,11 +200,13 @@ clean:\n@echo \"[Clean] Removing $(VEC) build outputs\"\nbatchbuild:\n+ # NEON is deliberately not here - needs a different CXX setting\n@+$(MAKE) -s VEC=sse2\n@+$(MAKE) -s VEC=sse4.2\n@+$(MAKE) -s VEC=avx2\nbatchclean:\n+ @+$(MAKE) -s clean VEC=neon\n@+$(MAKE) -s clean VEC=sse2\n@+$(MAKE) -s clean VEC=sse4.2\n@+$(MAKE) -s clean VEC=avx2\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -470,8 +470,6 @@ astcenc_error astcenc_context_alloc(\nreturn ASTCENC_ERR_BAD_PARAM;\n}\n- try\n- {\nctx = new astcenc_context;\nctx->thread_count = thread_count;\nctx->config = config;\n@@ -513,17 +511,12 @@ astcenc_error astcenc_context_alloc(\nsize_t worksize = sizeof(compress_symbolic_block_buffers) * thread_count;\nctx->working_buffers = aligned_malloc<compress_symbolic_block_buffers>(worksize , 32);\n- }\n-#endif\n- }\n- catch(const std::bad_alloc&)\n+ if (!ctx->working_buffers)\n{\n- term_block_size_descriptor(bsd);\n- delete bsd;\n- delete ctx;\n- *context = nullptr;\n- return ASTCENC_ERR_OUT_OF_MEM;\n+ goto error_oom;\n}\n+ }\n+#endif\n*context = ctx;\n@@ -534,6 +527,13 @@ astcenc_error astcenc_context_alloc(\nbuild_quantization_mode_table();\nreturn ASTCENC_SUCCESS;\n+\n+error_oom:\n+ term_block_size_descriptor(bsd);\n+ delete bsd;\n+ delete ctx;\n+ *context = nullptr;\n+ return ASTCENC_ERR_OUT_OF_MEM;\n}\nvoid astcenc_context_free(\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1185,8 +1185,8 @@ int cpu_supports_avx2();\n*\n* @param size The desired buffer size.\n* @param align The desired buffer alignment; must be 2^N.\n- * @returns The memory buffer pointer.\n- * @throw std::bad_alloc on allocation failure.\n+ *\n+ * @returns The memory buffer pointer or nullptr on allocation failure.\n*/\ntemplate<typename T>\nT* aligned_malloc(size_t size, size_t align)\n@@ -1202,7 +1202,7 @@ T* aligned_malloc(size_t size, size_t align)\nif (error || (!ptr))\n{\n- throw std::bad_alloc();\n+ return nullptr;\n}\nreturn static_cast<T*>(ptr);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove exceptions from core library Note that stdlib can still throw them, as we are e.g. not using new(nothrow).
61,745
21.07.2020 09:29:53
-3,600
979ebe47545d38f3aa9f65647b4841696745b961
Add vec alignment defines to Windows builds
[ { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-avx2.vcxproj", "new_path": "Source/VS2019/astcenc-avx2.vcxproj", "diff": "<ClCompile>\n<Optimization>Disabled</Optimization>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse2.vcxproj", "new_path": "Source/VS2019/astcenc-sse2.vcxproj", "diff": "<ClCompile>\n<Optimization>Disabled</Optimization>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "new_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "diff": "<ClCompile>\n<Optimization>Disabled</Optimization>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add vec alignment defines to Windows builds
61,745
22.07.2020 08:35:33
-3,600
afe84b8cdd50a1e03fbc1ad6dc48133158377dd6
Skip key-value pairs in compresed KTX files
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -1079,12 +1079,13 @@ bool load_ktx_compressed_image(\nsize_t actual = fread(&hdr, 1, sizeof(hdr), f);\nif (actual != sizeof(hdr))\n{\n- printf(\"Failed to read header of KTX file %s\\n\", filename);\n+ printf(\"Failed to read header from %s\\n\", filename);\nfclose(f);\nreturn true;\n}\n- if (memcmp(hdr.magic, ktx_magic, 12) != 0 || (hdr.endianness != 0x04030201 && hdr.endianness != 0x01020304))\n+ if (memcmp(hdr.magic, ktx_magic, 12) != 0 ||\n+ (hdr.endianness != 0x04030201 && hdr.endianness != 0x01020304))\n{\nprintf(\"File %s does not have a valid KTX header\\n\", filename);\nfclose(f);\n@@ -1098,7 +1099,8 @@ bool load_ktx_compressed_image(\nktx_header_switch_endianness(&hdr);\n}\n- if (hdr.gl_type != 0 || hdr.gl_format != 0 || hdr.gl_type_size != 1 || hdr.gl_base_internal_format != GL_RGBA)\n+ if (hdr.gl_type != 0 || hdr.gl_format != 0 || hdr.gl_type_size != 1 ||\n+ hdr.gl_base_internal_format != GL_RGBA)\n{\nprintf(\"File %s is not a compressed ASTC file\\n\", filename);\nfclose(f);\n@@ -1113,29 +1115,41 @@ bool load_ktx_compressed_image(\nreturn true;\n}\n+ // Skip over any key-value pairs\n+ int seekerr;\n+ seekerr = fseek(f, hdr.bytes_of_key_value_data, SEEK_CUR);\n+ if (seekerr)\n+ {\n+ printf(\"Failed to skip key-value pairs in %s\\n\", filename);\n+ fclose(f);\n+ }\n+\n+ // Read the length of the data and endianess convert\nunsigned int data_len;\nactual = fread(&data_len, 1, sizeof(data_len), f);\nif (actual != sizeof(data_len))\n{\n- printf(\"Failed to read data size of KTX file %s\\n\", filename);\n+ printf(\"Failed to read mip 0 size from %s\\n\", filename);\nfclose(f);\nreturn true;\n}\n+ if (switch_endianness)\n+ {\n+ data_len = u32_byterev(data_len);\n+ }\n+\n+ // Read the data\nunsigned char* data = new unsigned char[data_len];\nactual = fread(data, 1, data_len, f);\nif (actual != data_len)\n{\n- printf(\"Failed to data from KTX file %s\\n\", filename);\n+ printf(\"Failed to read mip 0 data from %s\\n\", filename);\nfclose(f);\n+ delete[] data;\nreturn true;\n}\n- if (switch_endianness)\n- {\n- data_len = u32_byterev(data_len);\n- }\n-\nimg.block_x = fmt->x;\nimg.block_y = fmt->y;\nimg.block_z = fmt->z == 0 ? 1 : fmt->z;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Skip key-value pairs in compresed KTX files
61,745
27.07.2020 10:33:07
-3,600
88825d337b5732e84fd0323dc8e69e616634b6d5
Avoid __builtin_cpu_supports for Ubunutu 16.04 compat This commit replaces __builtin_cpu_supports() with manual cpuid queries due to an issue with the default compiler on Ubuntu 16.04 when building shared objects.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "@@ -42,6 +42,8 @@ static void detect_cpu_isa()\n__cpuid(data, 0);\nint num_id = data[0];\n+ g_cpu_has_sse42 = 0;\n+ g_cpu_has_popcnt = 0;\nif (num_id >= 1)\n{\n__cpuidex(data, 1, 0);\n@@ -51,6 +53,7 @@ static void detect_cpu_isa()\ng_cpu_has_popcnt = data[2] & (1 << 23) ? 1 : 0;\n}\n+ g_cpu_has_avx2 = 0;\nif (num_id >= 7) {\n__cpuidex(data, 7, 0);\n// AVX2 = Bank 7, EBX, bit 5\n@@ -62,11 +65,28 @@ static void detect_cpu_isa()\nPlatform code for GCC and Clang\n============================================================================ */\n#else\n+#include <cpuid.h>\n+\nstatic void detect_cpu_isa()\n{\n- g_cpu_has_sse42 = __builtin_cpu_supports(\"sse4.2\") ? 1 : 0;\n- g_cpu_has_popcnt = __builtin_cpu_supports(\"popcnt\") ? 1 : 0;\n- g_cpu_has_avx2 = __builtin_cpu_supports(\"avx2\") ? 1 : 0;\n+ unsigned int data[4];\n+\n+ g_cpu_has_sse42 = 0;\n+ g_cpu_has_popcnt = 0;\n+ if (__get_cpuid_count(1, 0, &data[0], &data[1], &data[2], &data[3]))\n+ {\n+ // SSE42 = Bank 1, ECX, bit 20\n+ g_cpu_has_sse42 = data[2] & (1 << 20) ? 1 : 0;\n+ // POPCNT = Bank 1, ECX, bit 23\n+ g_cpu_has_popcnt = data[2] & (1 << 23) ? 1 : 0;\n+ }\n+\n+ g_cpu_has_avx2 = 0;\n+ if (__get_cpuid_count(7, 0, &data[0], &data[1], &data[2], &data[3]))\n+ {\n+ // AVX2 = Bank 7, EBX, bit 5\n+ g_cpu_has_avx2 = data[1] & (1 << 5) ? 1 : 0;\n+ }\n}\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid __builtin_cpu_supports for Ubunutu 16.04 compat This commit replaces __builtin_cpu_supports() with manual cpuid queries due to an issue with the default compiler on Ubuntu 16.04 when building shared objects.
61,745
27.07.2020 10:40:35
-3,600
0d5c61de83ef427f0e980d469178573ec7dcc47e
Brace on newline changes
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_platform_isa_detection.cpp", "new_path": "Source/astcenc_platform_isa_detection.cpp", "diff": "@@ -54,7 +54,8 @@ static void detect_cpu_isa()\n}\ng_cpu_has_avx2 = 0;\n- if (num_id >= 7) {\n+ if (num_id >= 7)\n+ {\n__cpuidex(data, 7, 0);\n// AVX2 = Bank 7, EBX, bit 5\ng_cpu_has_avx2 = data[1] & (1 << 5) ? 1 : 0;\n@@ -94,7 +95,9 @@ static void detect_cpu_isa()\nint cpu_supports_sse42()\n{\nif (g_cpu_has_sse42 == -1)\n+ {\ndetect_cpu_isa();\n+ }\nreturn g_cpu_has_sse42;\n}\n@@ -103,7 +106,9 @@ int cpu_supports_sse42()\nint cpu_supports_popcnt()\n{\nif (g_cpu_has_popcnt == -1)\n+ {\ndetect_cpu_isa();\n+ }\nreturn g_cpu_has_popcnt;\n}\n@@ -112,7 +117,9 @@ int cpu_supports_popcnt()\nint cpu_supports_avx2()\n{\nif (g_cpu_has_avx2 == -1)\n+ {\ndetect_cpu_isa();\n+ }\nreturn g_cpu_has_avx2;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Brace on newline changes
61,745
27.07.2020 14:56:47
-3,600
b56ab3680d7bf2ba8754ed6edf723520bf59789c
Add notes on 2.x series binaries
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -68,10 +68,27 @@ options ranging from 0.89 bits/pixel up to 8 bits/pixel.\n# Prebuilt binaries\n-Prebuilt release build binaries of `astcenc` for 64-bit Linux, macOS, and\n-Windows are available in the\n+Release build binaries for the `astcenc` stable releases are provided in the\n[GitHub Releases page](https://github.com/ARM-software/astc-encoder/releases).\n-Note that currently no 2.x series pre-built binaries are available.\n+Binaries are provided for 64-bit builds on Windows, macOS, and Linux.\n+\n+## astcenc 2.x binaries\n+\n+The current builds of the astcenc 2.x series are provided as multiple binaries,\n+each tuned for a specific SIMD instruction set. We provide, in order of\n+increasing performance:\n+\n+* `astcenc-sse2` - uses SSE2\n+* `astcenc-sse4.2` - uses SSE4.2 and POPCNT\n+* `astcenc-avx2` - uses SSE4.2, POPCNT, and AVX2\n+\n+The SSE2 builds will work on all x86-64 host machines, but it is the slowest of\n+the three. The other two require extended CPU instruction set support which is\n+not universally available.\n+\n+It is worth noting that the three binaries do not produce identical output\n+images; there are minor output differences caused by variations in\n+floating-point rounding.\n# Getting started\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add notes on 2.x series binaries
61,745
07.08.2020 22:05:23
-3,600
acd27bf1577892ca0c17bf2236d1884d8b39e8c1
Update README.md for 2.0 release
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -25,17 +25,6 @@ This project is licensed under the Apache 2.0 license. By downloading any\ncomponent from this repository you acknowledge that you accept terms specified\nin the [LICENSE.txt](LICENSE.txt) file.\n-# Branches\n-\n-The `master` branch is an active development branch for the next major release\n-of the compressor; version 2.x. It aims to be a stable branch, but as it is\n-still under development expect changes to both the command line and the\n-quality-performance trade offs the compressor is making.\n-\n-The `1.x` branch is a maintenance branch for the 1.x release series. It is\n-stable and we will now only land bug fixes for this branch; no new\n-functionality or performance improvements should be expected.\n-\n# Encoder feature support\nThe encoder supports compression of low dynamic range (BMP, JPEG, PNG, TGA) and\n@@ -72,6 +61,8 @@ Release build binaries for the `astcenc` stable releases are provided in the\n[GitHub Releases page](https://github.com/ARM-software/astc-encoder/releases).\nBinaries are provided for 64-bit builds on Windows, macOS, and Linux.\n+The latest stable release is version 2.0.\n+\n## astcenc 2.x binaries\nThe current builds of the astcenc 2.x series are provided as multiple binaries,\n@@ -90,6 +81,14 @@ It is worth noting that the three binaries do not produce identical output\nimages; there are minor output differences caused by variations in\nfloating-point rounding.\n+## Repository branches\n+\n+The `master` branch is an active development branch for the compressor. It aims\n+to be a stable branch, but as it is used for development expect it to change.\n+\n+The `1.x` branch is a maintenance branch for the 1.x release series. It is\n+no longer under active development.\n+\n# Getting started\nOpen a terminal, change to the appropriate directory for your system, and run\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update README.md for 2.0 release
61,745
06.09.2020 22:05:26
-3,600
9ab7d2cf16f5af717dca6a6162324e6c0cd8db7a
Add new RGBA images to generated test set
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -14,6 +14,7 @@ Source/VS2019/*Debug\nSource/VS2019/*.exe\nTest/DocOut\nTest/Images/Kodak\n+Test/Images/KodakSim\nTest/Images/Scratch*\nTestOutput\nDocs/LibraryInterface.md\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -1357,25 +1357,26 @@ class CLIPTest(CLITestBase):\nTest that a round-trip and a file-based round-trip give same result.\n\"\"\"\ninputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\n- p1DecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+ p1DecFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\np2CompFile = self.get_tmp_image_path(\"LDR\", \"comp\")\n- p2DecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+ p2DecFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n# Compute the first image using a direct round-trip\n- command = [self.binary, \"-tl\", inputFile, p1DecompFile, \"4x4\", \"-medium\"]\n+ command = [self.binary, \"-tl\", inputFile, p1DecFile, \"4x4\", \"-medium\"]\nself.exec(command)\n# Compute the first image using a file-based round-trip\ncommand = [self.binary, \"-cl\", inputFile, p2CompFile, \"4x4\", \"-medium\"]\nself.exec(command)\n- command = [self.binary, \"-dl\", p2CompFile, p2DecompFile]\n+ command = [self.binary, \"-dl\", p2CompFile, p2DecFile]\nself.exec(command)\n# RMSE should be the same\n- p1RMSE = sum(self.get_channel_rmse(inputFile, p1DecompFile))\n- p2RMSE = sum(self.get_channel_rmse(inputFile, p2DecompFile))\n+ p1RMSE = sum(self.get_channel_rmse(inputFile, p1DecFile))\n+ p2RMSE = sum(self.get_channel_rmse(inputFile, p2DecFile))\nself.assertEqual(p1RMSE, p2RMSE)\n+\nclass CLINTest(CLITestBase):\n\"\"\"\nCommand line interface negative tests.\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image_dl.py", "new_path": "Test/astc_test_image_dl.py", "diff": "@@ -26,6 +26,8 @@ import os\nimport sys\nimport urllib.request\n+from PIL import Image\n+\nTEST_IMAGE_DIR = os.path.join(\"Test\", \"Images\")\n@@ -52,17 +54,77 @@ def download(testSet, index, srcUrl, dstPath):\nprint(\"%s image %u: Skipping\" % (testSet, index))\n+def make_landscape(imgPath):\n+ \"\"\"\n+ Make an image on disk landscape aspect (edit in place)\n+\n+ Args:\n+ imgPath: The pth of the image on disk.\n+ \"\"\"\n+ img = Image.open(imgPath)\n+ if img.size[0] < img.size[1]:\n+ img = img.rotate(90, expand=True)\n+ img.save(imgPath)\n+\n+\n+def make_mixed_image(imgPathA, imgPathB, dstPath):\n+ \"\"\"\n+ Make image consisting of RGB from A's RGB, and alpha from B's luminance.\n+\n+ Args:\n+ imgPathA: The path of input A on disk.\n+ imgPathB: The path of input B on disk.\n+ dstPath: The path of the destination.\n+ \"\"\"\n+ imgA = Image.open(imgPathA)\n+ imgB = Image.open(imgPathB).convert(\"L\")\n+\n+ imgA.putalpha(imgB)\n+\n+ dirs = os.path.dirname(dstPath)\n+ if not os.path.exists(dirs):\n+ os.makedirs(dirs)\n+\n+ imgA.save(dstPath)\n+\n+\ndef retrieve_kodak_set():\n\"\"\"\nDownload the public domain Kodak image set.\n+\n+ To make test set mosaics easier to build we rotate images to make\n+ everything landscape.\n\"\"\"\ntestSet = \"Kodak\"\n+\n+ # Download the original RGB images\nfor i in range(1, 25):\nfle = \"ldr-rgb-kodak%02u.png\" % i\ndst = os.path.join(TEST_IMAGE_DIR, \"Kodak\", \"LDR-RGB\", fle)\nsrc = \"http://r0k.us/graphics/kodak/kodak/kodim%02u.png\" % i\ndownload(testSet, i, src, dst)\n+ # Canonicalize image aspect\n+ make_landscape(dst)\n+\n+ # Make some correlated alpha RGBA images\n+ fle = \"ldr-rgb-kodak%02u.png\" # Expand later\n+ pattern = os.path.join(TEST_IMAGE_DIR, \"Kodak\", \"LDR-RGB\", fle)\n+\n+ for i in (22, 23):\n+ imgA = pattern % i\n+ fle = \"ldr-rgba-kodak%02u+ca.png\" % i\n+ dst = os.path.join(TEST_IMAGE_DIR, \"KodakSim\", \"LDR-RGBA\", fle)\n+ make_mixed_image(imgA, imgA, dst)\n+\n+ # Make some non-correlated alpha RGBA images\n+ for i, j in ((22, 24), (23, 20)):\n+ imgA = pattern % i\n+ imgB = pattern % j\n+ fle = \"ldr-rgba-kodak%02u+%02u+nca.png\" % (i, j)\n+ dst = os.path.join(TEST_IMAGE_DIR, \"KodakSim\", \"LDR-RGBA\", fle)\n+ make_mixed_image(imgA, imgB, dst)\n+\ndef main():\n\"\"\"\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add new RGBA images to generated test set
61,745
06.09.2020 22:38:38
-3,600
5fe9295d1144e52c341e87061a07333b36ca19d0
Add summary perforamnce reports to test runs
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -224,6 +224,11 @@ def run_test_set(encoder, testRef, testSet, blockSizes, testRuns):\nif testRef:\nrefResult = testRef.get_matching_record(res)\nres.set_status(determine_result(image, refResult, res))\n+\n+ res.tTimeRel = refResult.tTime / res.tTime\n+ res.cTimeRel = refResult.cTime / res.cTime\n+ res.psnrRel = res.psnr - refResult.psnr\n+\nres = format_result(image, refResult, res)\nelse:\nres = format_solo_result(image, res)\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/resultset.py", "new_path": "Test/testlib/resultset.py", "diff": "@@ -26,6 +26,7 @@ compared against a set of reference results created by an earlier test run.\nimport csv\nimport enum\n+import numpy as np\n@enum.unique\n@@ -55,6 +56,9 @@ class ResultSummary():\npasses: The number of tests that passed.\nwarnings: The number of tests that produced a warning.\nfails: The number of tests that failed.\n+ tTimes: Total time speedup vs reference (<1 is slower, >1 is faster).\n+ cTimes: Coding time speedup vs reference (<1 is slower, >1 is faster).\n+ psnrs: Coding time quality vs reference (<0 is worse, >0 is better).\n\"\"\"\ndef __init__(self):\n@@ -66,6 +70,10 @@ class ResultSummary():\nself.warnings = 0\nself.fails = 0\n+ self.tTimes = []\n+ self.cTimes = []\n+ self.psnrs = []\n+\ndef add_record(self, record):\n\"\"\"\nAdd a record to this summary.\n@@ -82,6 +90,11 @@ class ResultSummary():\nelse:\nself.notruns += 1\n+ if record.tTimeRel is not None:\n+ self.tTimes.append(record.tTimeRel)\n+ self.cTimes.append(record.cTimeRel)\n+ self.psnrs.append(record.psnrRel)\n+\ndef get_worst_result(self):\n\"\"\"\nGet the worst result in this set.\n@@ -101,9 +114,22 @@ class ResultSummary():\nreturn Result.NOTRUN\ndef __str__(self):\n+ # Overall pass/fail results\noverall = self.get_worst_result().name\ndat = (overall, self.passes, self.warnings, self.fails)\n- return \"Set Status: %s (Pass: %u | Warn: %u | Fail: %u)\" % dat\n+ result = [\"\\nSet Status: %s (Pass: %u | Warn: %u | Fail: %u)\" % dat]\n+\n+ # Performance summaries\n+ dat = (np.mean(self.tTimes), np.var(self.tTimes))\n+ result.append(\"\\nTotal time: Mean: %+0.2fx Var: %0.2fx\" % dat)\n+\n+ dat = (np.mean(self.cTimes), np.var(self.cTimes))\n+ result.append(\"Coding time: Mean: %+0.2fx Var: %0.2fx\" % dat)\n+\n+ dat = (np.mean(self.psnrs), np.var(self.psnrs))\n+ result.append(\"Image quality: Mean: %+0.2f dB Var: %0.2f dB\" % dat)\n+\n+ return \"\\n\".join(result)\nclass Record():\n@@ -129,6 +155,9 @@ class Record():\npsnr (float): The image quality PSNR, in dB.\ntTime (float): The total compression time, in seconds.\ncTime (float): The coding compression time, in seconds.\n+ tTimeRel (float): The relative total time speedup vs reference.\n+ cTimeRel (float): The relative coding time speedup vs reference.\n+ psnrRel (float): The relative PSNR dB vs reference.\n\"\"\"\nself.blkSz = blkSz\nself.name = name\n@@ -137,6 +166,10 @@ class Record():\nself.cTime = cTime\nself.status = Result.NOTRUN\n+ self.tTimeRel = None\n+ self.cTimeRel = None\n+ self.psnrRel = None\n+\ndef set_status(self, result):\n\"\"\"\nSet the result status.\n@@ -231,6 +264,7 @@ class ResultSet():\nsummary = ResultSummary()\nfor record in self.records:\nsummary.add_record(record)\n+\nreturn summary\ndef save_to_file(self, filePath):\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add summary perforamnce reports to test runs
61,745
07.09.2020 00:05:04
-3,600
b8db423556f4c2c5537da126ccf723b68e4ef4ca
Updated Khronos image references for 2.0
[ { "change_type": "MODIFY", "old_path": "Test/Images/Khronos/astc_reference-2.0-avx2_results.csv", "new_path": "Test/Images/Khronos/astc_reference-2.0-avx2_results.csv", "diff": "Image Set,Block Size,Name,PSNR,Total Time,Coding Time\n-Khronos,4x4,ldr-l-occlusion.png,70.86035,0.410,0.310\n-Khronos,4x4,ldr-rgb-diffuse.png,54.77733,14.460,13.880\n-Khronos,4x4,ldr-rgb-emissive.png,60.85045,0.440,0.340\n-Khronos,4x4,ldr-rgb-metalrough.png,44.97128,4.590,4.410\n-Khronos,4x4,ldr-rgb-metalrough2.png,44.07510,26.540,25.860\n-Khronos,4x4,ldr-rgba-base.png,44.06403,5.660,5.450\n-Khronos,4x4,ldr-rgba-diffuse.png,44.44850,3.800,3.620\n-Khronos,4x4,ldr-rgba-specgloss.png,42.47283,7.430,7.190\n-Khronos,4x4,ldr-xy-normal1.png,48.48679,6.210,5.970\n-Khronos,4x4,ldr-xy-normal2.png,54.35627,14.170,13.520\n-Khronos,5x5,ldr-l-occlusion.png,58.71131,0.580,0.490\n-Khronos,5x5,ldr-rgb-diffuse.png,49.81100,8.690,8.120\n+Khronos,4x4,ldr-l-occlusion.png,70.83558,0.390,0.300\n+Khronos,4x4,ldr-rgb-diffuse.png,54.77676,13.970,13.380\n+Khronos,4x4,ldr-rgb-emissive.png,60.85045,0.440,0.330\n+Khronos,4x4,ldr-rgb-metalrough.png,44.97133,4.480,4.300\n+Khronos,4x4,ldr-rgb-metalrough2.png,44.07510,25.870,25.190\n+Khronos,4x4,ldr-rgba-base.png,44.06403,5.610,5.390\n+Khronos,4x4,ldr-rgba-diffuse.png,44.44849,3.720,3.530\n+Khronos,4x4,ldr-rgba-specgloss.png,42.47281,7.190,6.950\n+Khronos,4x4,ldr-xy-normal1.png,48.48682,6.040,5.800\n+Khronos,4x4,ldr-xy-normal2.png,54.35492,13.610,12.950\n+Khronos,5x5,ldr-l-occlusion.png,58.76360,0.620,0.520\n+Khronos,5x5,ldr-rgb-diffuse.png,49.81364,8.430,7.860\nKhronos,5x5,ldr-rgb-emissive.png,56.20314,0.460,0.360\n-Khronos,5x5,ldr-rgb-metalrough.png,40.50106,4.860,4.680\n-Khronos,5x5,ldr-rgb-metalrough2.png,39.54918,26.440,25.770\n-Khronos,5x5,ldr-rgba-base.png,39.80310,5.610,5.390\n-Khronos,5x5,ldr-rgba-diffuse.png,39.93856,3.800,3.620\n-Khronos,5x5,ldr-rgba-specgloss.png,39.05463,7.370,7.140\n-Khronos,5x5,ldr-xy-normal1.png,44.18346,6.860,6.620\n-Khronos,5x5,ldr-xy-normal2.png,49.31975,18.800,18.160\n-Khronos,6x6,ldr-l-occlusion.png,52.11003,0.910,0.820\n-Khronos,6x6,ldr-rgb-diffuse.png,45.75278,7.900,7.330\n-Khronos,6x6,ldr-rgb-emissive.png,52.73920,0.520,0.410\n-Khronos,6x6,ldr-rgb-metalrough.png,37.06972,5.450,5.260\n-Khronos,6x6,ldr-rgb-metalrough2.png,36.80112,28.310,27.650\n-Khronos,6x6,ldr-rgba-base.png,36.90713,6.790,6.570\n-Khronos,6x6,ldr-rgba-diffuse.png,36.72718,4.780,4.600\n-Khronos,6x6,ldr-rgba-specgloss.png,36.71283,7.600,7.370\n-Khronos,6x6,ldr-xy-normal1.png,41.33108,4.940,4.700\n-Khronos,6x6,ldr-xy-normal2.png,46.61175,13.510,12.880\n-Khronos,8x8,ldr-l-occlusion.png,45.97299,0.790,0.700\n-Khronos,8x8,ldr-rgb-diffuse.png,40.86687,7.290,6.740\n-Khronos,8x8,ldr-rgb-emissive.png,47.71896,0.460,0.360\n-Khronos,8x8,ldr-rgb-metalrough.png,32.87011,5.240,5.060\n-Khronos,8x8,ldr-rgb-metalrough2.png,33.62420,29.430,28.790\n-Khronos,8x8,ldr-rgba-base.png,33.32482,7.120,6.930\n-Khronos,8x8,ldr-rgba-diffuse.png,32.77119,5.520,5.340\n-Khronos,8x8,ldr-rgba-specgloss.png,33.69351,7.670,7.450\n-Khronos,8x8,ldr-xy-normal1.png,37.60663,2.800,2.580\n-Khronos,8x8,ldr-xy-normal2.png,42.76908,3.610,3.000\n-Khronos,12x12,ldr-l-occlusion.png,42.22431,0.400,0.310\n-Khronos,12x12,ldr-rgb-diffuse.png,36.55695,6.960,6.420\n-Khronos,12x12,ldr-rgb-emissive.png,42.49384,0.550,0.440\n-Khronos,12x12,ldr-rgb-metalrough.png,29.30859,5.090,4.910\n-Khronos,12x12,ldr-rgb-metalrough2.png,30.74511,26.170,25.540\n-Khronos,12x12,ldr-rgba-base.png,29.91806,5.610,5.420\n-Khronos,12x12,ldr-rgba-diffuse.png,29.24359,5.290,5.120\n-Khronos,12x12,ldr-rgba-specgloss.png,30.71173,6.910,6.700\n-Khronos,12x12,ldr-xy-normal1.png,33.73169,2.420,2.210\n-Khronos,12x12,ldr-xy-normal2.png,38.38530,3.050,2.510\n+Khronos,5x5,ldr-rgb-metalrough.png,40.50173,4.760,4.570\n+Khronos,5x5,ldr-rgb-metalrough2.png,39.54922,26.080,25.390\n+Khronos,5x5,ldr-rgba-base.png,39.80318,5.550,5.330\n+Khronos,5x5,ldr-rgba-diffuse.png,39.93867,3.700,3.510\n+Khronos,5x5,ldr-rgba-specgloss.png,39.05467,7.270,7.030\n+Khronos,5x5,ldr-xy-normal1.png,44.18340,6.750,6.500\n+Khronos,5x5,ldr-xy-normal2.png,49.31884,18.420,17.780\n+Khronos,6x6,ldr-l-occlusion.png,52.33557,0.940,0.840\n+Khronos,6x6,ldr-rgb-diffuse.png,45.82520,8.020,7.460\n+Khronos,6x6,ldr-rgb-emissive.png,52.74083,0.510,0.410\n+Khronos,6x6,ldr-rgb-metalrough.png,37.07510,5.390,5.200\n+Khronos,6x6,ldr-rgb-metalrough2.png,36.80134,27.950,27.280\n+Khronos,6x6,ldr-rgba-base.png,36.90802,6.700,6.480\n+Khronos,6x6,ldr-rgba-diffuse.png,36.72820,4.680,4.500\n+Khronos,6x6,ldr-rgba-specgloss.png,36.71316,7.460,7.230\n+Khronos,6x6,ldr-xy-normal1.png,41.33188,4.800,4.570\n+Khronos,6x6,ldr-xy-normal2.png,46.62565,13.350,12.720\n+Khronos,8x8,ldr-l-occlusion.png,46.10532,0.870,0.780\n+Khronos,8x8,ldr-rgb-diffuse.png,40.96542,7.850,7.310\n+Khronos,8x8,ldr-rgb-emissive.png,47.72543,0.460,0.350\n+Khronos,8x8,ldr-rgb-metalrough.png,32.88533,5.270,5.070\n+Khronos,8x8,ldr-rgb-metalrough2.png,33.62592,28.630,27.980\n+Khronos,8x8,ldr-rgba-base.png,33.32982,7.070,6.880\n+Khronos,8x8,ldr-rgba-diffuse.png,32.77582,5.510,5.330\n+Khronos,8x8,ldr-rgba-specgloss.png,33.69604,7.600,7.380\n+Khronos,8x8,ldr-xy-normal1.png,37.61658,2.840,2.620\n+Khronos,8x8,ldr-xy-normal2.png,42.85673,4.420,3.830\n+Khronos,12x12,ldr-l-occlusion.png,42.44593,0.570,0.480\n+Khronos,12x12,ldr-rgb-diffuse.png,36.66275,7.690,7.170\n+Khronos,12x12,ldr-rgb-emissive.png,42.51213,0.540,0.430\n+Khronos,12x12,ldr-rgb-metalrough.png,29.32287,5.180,4.990\n+Khronos,12x12,ldr-rgb-metalrough2.png,30.75340,25.960,25.320\n+Khronos,12x12,ldr-rgba-base.png,29.92335,5.590,5.400\n+Khronos,12x12,ldr-rgba-diffuse.png,29.24742,5.280,5.100\n+Khronos,12x12,ldr-rgba-specgloss.png,30.71525,6.890,6.670\n+Khronos,12x12,ldr-xy-normal1.png,33.76117,2.670,2.470\n+Khronos,12x12,ldr-xy-normal2.png,38.48006,4.420,3.890\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Updated Khronos image references for 2.0
61,745
07.09.2020 00:07:09
-3,600
330cdf5d10f6993ec71d03e693ea58f493553892
Remove initital fast pass for 1 partition 1 plane The optimization rarely triggers outside of synthetic test content, and costs real content 1-2% performance.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1231,23 +1231,12 @@ float compress_symbolic_block(\nfloat mode_cutoff = ctx.config.tune_block_mode_limit / 100.0f;\n- // next, test mode #0. This mode uses 1 plane of weights and 1 partition.\n- // we test it twice, first with a modecutoff of 0, then with the specified mode-cutoff.\n- // This causes an early-out that speeds up encoding of \"easy\" content.\n+ // Test 1 plane of weights and 1 partition.\n+ compress_symbolic_block_fixed_partition_1_plane(\n+ decode_mode, mode_cutoff, ctx.config.tune_refinement_limit, bsd,\n+ 1, 0, blk, ewb, tempblocks, &tmpbuf->planes);\n- float modecutoffs[2];\n- float errorval_mult[2] = { 2.5, 1 };\n- modecutoffs[0] = 0;\n- modecutoffs[1] = mode_cutoff;\n-\n- float best_errorval_in_mode;\n- for (int i = 0; i < 2; i++)\n- {\n- compress_symbolic_block_fixed_partition_1_plane(decode_mode, modecutoffs[i], ctx.config.tune_refinement_limit, bsd, 1, // partition count\n- 0, // partition index\n- blk, ewb, tempblocks, &tmpbuf->planes);\n-\n- best_errorval_in_mode = 1e30f;\n+ float best_errorval_in_mode = 1e30f;\nfor (int j = 0; j < 4; j++)\n{\nif (tempblocks[j].error_block)\n@@ -1256,7 +1245,7 @@ float compress_symbolic_block(\n}\ndecompress_symbolic_block(decode_mode, bsd, xpos, ypos, zpos, tempblocks + j, temp);\n- float errorval = compute_imageblock_difference(bsd, blk, temp, ewb) * errorval_mult[i];\n+ float errorval = compute_imageblock_difference(bsd, blk, temp, ewb);\nif (errorval < best_errorval_in_mode)\n{\n@@ -1275,7 +1264,6 @@ float compress_symbolic_block(\n{\ngoto END_OF_TESTS;\n}\n- }\nint is_normal_map;\nfloat lowest_correl;\n@@ -1303,11 +1291,9 @@ float compress_symbolic_block(\ncontinue;\n}\n- compress_symbolic_block_fixed_partition_2_planes(decode_mode, mode_cutoff, ctx.config.tune_refinement_limit,\n- bsd, 1, // partition count\n- 0, // partition index\n- i, // the color component to test a separate plane of weights for.\n- blk, ewb, tempblocks, &tmpbuf->planes);\n+ compress_symbolic_block_fixed_partition_2_planes(\n+ decode_mode, mode_cutoff, ctx.config.tune_refinement_limit, bsd,\n+ 1, 0, i, blk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\nfor (int j = 0; j < 4; j++)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove initital fast pass for 1 partition 1 plane The optimization rarely triggers outside of synthetic test content, and costs real content 1-2% performance.
61,745
07.09.2020 00:10:08
-3,600
ce20204e1826ef9ddae26ad44dbfef052f31b1ef
Explicit braces
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1270,7 +1270,9 @@ float compress_symbolic_block(\nprepare_block_statistics(bsd->texel_count, blk, ewb, &is_normal_map, &lowest_correl);\nif (is_normal_map && lowest_correl < 0.99f)\n+ {\nlowest_correl = 0.99f;\n+ }\n// next, test the four possible 1-partition, 2-planes modes\nfor (int i = 0; i < 4; i++)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Explicit braces
61,745
10.09.2020 08:59:36
-3,600
aaee2df30fa31a58a30b9405c96b0d4fdbc6b3cc
Avoid 1 partition 1 plane early-out for small blocks The optimization is actually actually a de-optimization for both performance and image quality for 4x4 and 5x4 blocks. This PR changes it to be conditional based on current block size.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1231,9 +1231,13 @@ float compress_symbolic_block(\nfloat mode_cutoff = ctx.config.tune_block_mode_limit / 100.0f;\n- // next, test mode #0. This mode uses 1 plane of weights and 1 partition.\n- // we test it twice, first with a modecutoff of 0, then with the specified mode-cutoff.\n- // This causes an early-out that speeds up encoding of \"easy\" content.\n+ // Trial using 1 plane of weights and 1 partition.\n+\n+ // Most of the time we test it twice, first with a mode cutoff of 0 and\n+ // then with the specified mode cutoff. This causes an early-out that\n+ // speeds up encoding of easy blocks. However, this optimization is\n+ // disabled for 4x4 and 5x4 blocks where it nearly always slows down the\n+ // compression and slightly reduces image quality.\nfloat modecutoffs[2];\nfloat errorval_mult[2] = { 2.5, 1 };\n@@ -1241,7 +1245,9 @@ float compress_symbolic_block(\nmodecutoffs[1] = mode_cutoff;\nfloat best_errorval_in_mode;\n- for (int i = 0; i < 2; i++)\n+\n+ int start_trial = bsd->texel_count < TUNE_MIN_TEXELS_MODE0_FASTPATH ? 1 : 0;\n+ for (int i = start_trial; i < 2; i++)\n{\ncompress_symbolic_block_fixed_partition_1_plane(decode_mode, modecutoffs[i], ctx.config.tune_refinement_limit, bsd, 1, // partition count\n0, // partition index\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+// Compile-time tuning parameters\n+static const int TUNE_MIN_TEXELS_MODE0_FASTPATH { 25 };\n+\n// uncomment this macro to enable checking for inappropriate NaNs;\n// works on Linux only, and slows down encoding significantly.\n// #define DEBUG_CAPTURE_NAN\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid 1 partition 1 plane early-out for small blocks (#149) The optimization is actually actually a de-optimization for both performance and image quality for 4x4 and 5x4 blocks. This PR changes it to be conditional based on current block size.
61,745
10.09.2020 10:21:09
-3,600
753afe02c78c6e32165120c45aa0116b2c1e0d82
Switch to new Docker image
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Dockerfile", "new_path": "jenkins/build.Dockerfile", "diff": "FROM ubuntu:18.04\n-LABEL build.environment.version=\"1.0.0\"\n+LABEL build.environment.version=\"2.0.0\"\nRUN useradd -u 1001 -U -m -c Jenkins jenkins\n" }, { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -14,7 +14,7 @@ pipeline {\nstage('Linux') {\nagent {\ndocker {\n- image 'astcenc:1.0.0'\n+ image 'astcenc:2.0.0'\nregistryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\nregistryCredentialsId 'cepe-artifactory-jenkins'\nlabel 'docker'\n@@ -148,7 +148,7 @@ pipeline {\nstage('Artifactory') {\nagent {\ndocker {\n- image 'astcenc:1.0.0'\n+ image 'astcenc:2.0.0'\nregistryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\nregistryCredentialsId 'cepe-artifactory-jenkins'\nlabel 'docker'\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Switch to new Docker image
61,745
11.09.2020 10:37:26
-3,600
f07c43108b1baa4a5bac613c35c01a5402a8651c
Refactor find_best_partitionings() We now only ever use a single result from this function, so we can refactor to track the single best result as we go along instead of storing all results in an array that gets scanned after-the-fact.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1356,8 +1356,8 @@ float compress_symbolic_block(\nint partition_indices_1plane[2];\nint partition_index_2planes;\n- find_best_partitionings(ctx.config.tune_partition_limit,\n- bsd, partition_count, blk, ewb,\n+ find_best_partitionings(bsd, blk, ewb, partition_count,\n+ ctx.config.tune_partition_limit,\n&(partition_indices_1plane[0]),\n&(partition_indices_1plane[1]),\n&partition_index_2planes);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -218,14 +218,14 @@ void compute_partition_error_color_weightings(\n/* main function to identify the best partitioning for a given number of texels */\nvoid find_best_partitionings(\n- int partition_search_limit,\nconst block_size_descriptor* bsd,\n- int partition_count,\n- const imageblock* pb,\n+ const imageblock* blk,\nconst error_weight_block* ewb,\n- int* best_partitions_uncorrelated,\n- int* best_partitions_samechroma,\n- int* best_partitions_dual_weight_planes\n+ int partition_count,\n+ int partition_search_limit,\n+ int* best_partition_uncorrelated,\n+ int* best_partition_samechroma,\n+ int* 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@@ -251,52 +251,41 @@ void find_best_partitionings(\nint partition_sequence[PARTITION_COUNT];\n- kmeans_compute_partition_ordering(bsd, partition_count, pb, partition_sequence);\n+ kmeans_compute_partition_ordering(bsd, partition_count, blk, partition_sequence);\nfloat weight_imprecision_estim_squared = weight_imprecision_estim * weight_imprecision_estim;\n- int uses_alpha = imageblock_uses_alpha(pb);\n+ int uses_alpha = imageblock_uses_alpha(blk);\nconst partition_info* ptab = get_partition_table(bsd, partition_count);\n- // partitioning errors assuming uncorrelated-chrominance endpoints\n- float uncorr_errors[PARTITION_COUNT];\n- // partitioning errors assuming same-chrominance endpoints\n- float samechroma_errors[PARTITION_COUNT];\n+ // Partitioning errors assuming uncorrelated-chrominance endpoints\n+ float uncorr_best_error { ERROR_CALC_DEFAULT };\n+ int uncorr_best_partition { 0 };\n- // partitioning errors assuming that one of the color channels\n- // is uncorrelated from all the other ones\n- float4 separate_errors[PARTITION_COUNT];\n+ // Partitioning errors assuming same-chrominance endpoints\n+ // Store two so we can always return one different to uncorr\n+ float samechroma_best_errors[2] { ERROR_CALC_DEFAULT, ERROR_CALC_DEFAULT };\n+ int samechroma_best_partitions[2] { 0, 0 };\n- int defacto_search_limit = PARTITION_COUNT - 1;\n+ // Partitioning errors assuming that one color component is uncorrelated\n+ float separate_best_error { ERROR_CALC_DEFAULT };\n+ int separate_best_partition { 0 };\n+ int separate_best_component { 0 };\nif (uses_alpha)\n{\n- for (int i = 0; i < PARTITION_COUNT; i++)\n+ for (int i = 0; i < partition_search_limit; i++)\n{\nint partition = partition_sequence[i];\n- int bk_partition_count = ptab[partition].partition_count;\n+ int bk_partition_count = ptab[partition].partition_count;\nif (bk_partition_count < partition_count)\n{\n- uncorr_errors[i] = 1e35f;\n- samechroma_errors[i] = 1e35f;\n- separate_errors[i] = float4(1e35f, 1e35f, 1e35f, 1e35f);\ncontinue;\n}\n- // the sentinel value for partitions above the search limit must be smaller\n- // than the sentinel value for invalid partitions\n- if (i >= partition_search_limit)\n- {\n- defacto_search_limit = i;\n- uncorr_errors[i] = 1e34f;\n- samechroma_errors[i] = 1e34f;\n- separate_errors[i] = float4(1e34f, 1e34f, 1e34f, 1e34f);\n- break;\n- }\n-\n// compute the weighting to give to each color channel\n// in each partition.\nfloat4 error_weightings[4];\n@@ -315,7 +304,7 @@ void find_best_partitionings(\nfloat4 averages[4];\nfloat4 directions_rgba[4];\n- compute_averages_and_directions_rgba(ptab + partition, pb, ewb,\n+ compute_averages_and_directions_rgba(ptab + partition, blk, ewb,\ncolor_scalefactors, averages,\ndirections_rgba);\n@@ -434,7 +423,7 @@ void find_best_partitionings(\nfloat samechroma_error = 0.0f;\nfloat4 separate_error = float4(0.0f, 0.0f, 0.0f, 0.0f);\ncompute_error_squared_rgba(ptab + partition,\n- pb,\n+ blk,\newb,\nproc_uncorr_lines,\nproc_samechroma_lines,\n@@ -453,8 +442,8 @@ void find_best_partitionings(\nfloat3 rgb_range[4];\nfloat alpha_range[4];\n- compute_alpha_range(bsd->texel_count, ptab + partition, pb, ewb, alpha_range);\n- compute_rgb_range(bsd->texel_count, ptab + partition, pb, ewb, rgb_range);\n+ compute_alpha_range(bsd->texel_count, ptab + partition, blk, ewb, alpha_range);\n+ compute_rgb_range(bsd->texel_count, ptab + partition, blk, ewb, rgb_range);\n/*\nCompute an estimate of error introduced by weight quantization imprecision.\n@@ -502,37 +491,67 @@ void find_best_partitionings(\nseparate_error.w += alpha_range[j] * alpha_range[j] * error_weights.w;\n}\n- uncorr_errors[i] = uncorr_error;\n- samechroma_errors[i] = samechroma_error;\n- separate_errors[i] = separate_error;\n+ if (uncorr_error < uncorr_best_error)\n+ {\n+ uncorr_best_error = uncorr_error;\n+ uncorr_best_partition = partition;\n+ }\n+\n+ if (samechroma_error < samechroma_best_errors[0])\n+ {\n+ samechroma_best_errors[1] = samechroma_best_errors[0];\n+ samechroma_best_partitions[1] = samechroma_best_partitions[0];\n+\n+ samechroma_best_errors[0] = samechroma_error;\n+ samechroma_best_partitions[0] = partition;\n+ }\n+ else if (samechroma_error < samechroma_best_errors[1])\n+ {\n+ samechroma_best_errors[1] = samechroma_error;\n+ samechroma_best_partitions[1] = partition;\n+ }\n+\n+ if (separate_error.x < separate_best_error)\n+ {\n+ separate_best_error = separate_error.x;\n+ separate_best_partition = partition;\n+ separate_best_component = 0;\n+ }\n+\n+ if (separate_error.y < separate_best_error)\n+ {\n+ separate_best_error = separate_error.y;\n+ separate_best_partition = partition;\n+ separate_best_component = 1;\n+ }\n+\n+ if (separate_error.z < separate_best_error)\n+ {\n+ separate_best_error = separate_error.z;\n+ separate_best_partition = partition;\n+ separate_best_component = 2;\n+ }\n+\n+ if (separate_error.w < separate_best_error)\n+ {\n+ separate_best_error = separate_error.w;\n+ separate_best_partition = partition;\n+ separate_best_component = 3;\n+ }\n}\n}\nelse\n{\n- for (int i = 0; i < PARTITION_COUNT; i++)\n+ for (int i = 0; i < partition_search_limit; i++)\n{\nint partition = partition_sequence[i];\nint bk_partition_count = ptab[partition].partition_count;\nif (bk_partition_count < partition_count)\n{\n- uncorr_errors[i] = 1e35f;\n- samechroma_errors[i] = 1e35f;\n- separate_errors[i] = float4(1e35f, 1e35f, 1e35f, 1e35f);\ncontinue;\n}\n- // the sentinel value for valid partitions above the search limit must be smaller\n- // than the sentinel value for invalid partitions\n- if (i >= partition_search_limit)\n- {\n- defacto_search_limit = i;\n- uncorr_errors[i] = 1e34f;\n- samechroma_errors[i] = 1e34f;\n- separate_errors[i] = float4(1e34f, 1e34f, 1e34f, 1e34f);\n- break;\n- }\n-\n// compute the weighting to give to each color channel\n// in each partition.\nfloat4 error_weightings[4];\n@@ -552,7 +571,7 @@ void find_best_partitionings(\nfloat3 averages[4];\nfloat3 directions_rgb[4];\n- compute_averages_and_directions_rgb(ptab + partition, pb, ewb, color_scalefactors, averages, directions_rgb);\n+ compute_averages_and_directions_rgb(ptab + partition, blk, ewb, color_scalefactors, averages, directions_rgb);\nline3 uncorr_lines[4];\nline3 samechroma_lines[4];\n@@ -652,7 +671,7 @@ void find_best_partitionings(\nfloat3 separate_error = float3(0.0f, 0.0f, 0.0f);\ncompute_error_squared_rgb(ptab + partition,\n- pb,\n+ blk,\newb,\nproc_uncorr_lines,\nproc_samechroma_lines,\n@@ -667,7 +686,7 @@ void find_best_partitionings(\n&separate_error);\nfloat3 rgb_range[4];\n- compute_rgb_range(bsd->texel_count, ptab + partition, pb, ewb, rgb_range);\n+ compute_rgb_range(bsd->texel_count, ptab + partition, blk, ewb, rgb_range);\n/*\ncompute an estimate of error introduced by weight imprecision.\n@@ -712,99 +731,56 @@ void find_best_partitionings(\nseparate_error.z += rgb_range[j].z * rgb_range[j].z * error_weights.z;\n}\n- uncorr_errors[i] = uncorr_error;\n- samechroma_errors[i] = samechroma_error;\n- separate_errors[i] = float4(separate_error.x, separate_error.y, separate_error.z, 0.0f);\n- }\n- }\n-\n- int best_uncorr_partition = 0;\n- int best_samechroma_partition = 0;\n- float best_uncorr_error = 1e30f;\n- float best_samechroma_error = 1e30f;\n-\n- for (int j = 0; j <= defacto_search_limit; j++)\n- {\n- if (uncorr_errors[j] < best_uncorr_error)\n+ if (uncorr_error < uncorr_best_error)\n{\n- best_uncorr_partition = j;\n- best_uncorr_error = uncorr_errors[j];\n- }\n+ uncorr_best_error = uncorr_error;\n+ uncorr_best_partition = partition;\n}\n- *best_partitions_uncorrelated = partition_sequence[best_uncorr_partition];\n- uncorr_errors[best_uncorr_partition] = 1e30f;\n- samechroma_errors[best_uncorr_partition] = 1e30f;\n-\n- for (int j = 0; j <= defacto_search_limit; j++)\n- {\n- if (samechroma_errors[j] < best_samechroma_error)\n+ if (samechroma_error < samechroma_best_errors[0])\n{\n- best_samechroma_partition = j;\n- best_samechroma_error = samechroma_errors[j];\n- }\n- }\n+ samechroma_best_errors[1] = samechroma_best_errors[0];\n+ samechroma_best_partitions[1] = samechroma_best_partitions[0];\n- *best_partitions_samechroma = partition_sequence[best_samechroma_partition];\n- samechroma_errors[best_samechroma_partition] = 1e30f;\n- uncorr_errors[best_samechroma_partition] = 1e30f;\n-\n- int best_partition = 0;\n- int best_component = 0;\n- float best_partition_error = 1e30f;\n-\n- for (int j = 0; j <= defacto_search_limit; j++)\n- {\n- if (separate_errors[j].x < best_partition_error)\n+ samechroma_best_errors[0] = samechroma_error;\n+ samechroma_best_partitions[0] = partition;\n+ }\n+ else if (samechroma_error < samechroma_best_errors[1])\n{\n- best_component = 0;\n- best_partition = j;\n- best_partition_error = separate_errors[j].x;\n+ samechroma_best_errors[1] = samechroma_error;\n+ samechroma_best_partitions[1] = partition;\n}\n- if (separate_errors[j].y < best_partition_error)\n+ if (separate_error.x < separate_best_error)\n{\n- best_component = 1;\n- best_partition = j;\n- best_partition_error = separate_errors[j].y;\n+ separate_best_error = separate_error.x;\n+ separate_best_partition = partition;\n+ separate_best_component = 0;\n}\n- if (separate_errors[j].z < best_partition_error)\n+ if (separate_error.y < separate_best_error)\n{\n- best_component = 2;\n- best_partition = j;\n- best_partition_error = separate_errors[j].z;\n+ separate_best_error = separate_error.y;\n+ separate_best_partition = partition;\n+ separate_best_component = 1;\n}\n- if (uses_alpha)\n- {\n- if (separate_errors[j].w < best_partition_error)\n+ if (separate_error.z < separate_best_error)\n{\n- best_component = 3;\n- best_partition = j;\n- best_partition_error = separate_errors[j].w;\n+ separate_best_error = separate_error.z;\n+ separate_best_partition = partition;\n+ separate_best_component = 2;\n}\n}\n}\n- switch(best_component)\n- {\n- case 0:\n- separate_errors[best_partition].x = 1e30f;\n- break;\n- case 1:\n- separate_errors[best_partition].y = 1e30f;\n- break;\n- case 2:\n- separate_errors[best_partition].z = 1e30f;\n- break;\n- case 3:\n- separate_errors[best_partition].w = 1e30f;\n- break;\n- }\n+ *best_partition_uncorrelated = uncorr_best_partition;\n+\n+ int index { samechroma_best_partitions[0] != uncorr_best_partition ? 0 : 1 };\n+ *best_partition_samechroma = samechroma_best_partitions[index];\n- best_partition = (best_component << PARTITION_BITS) | partition_sequence[best_partition & (PARTITION_COUNT - 1)];\n- *best_partitions_dual_weight_planes = best_partition;\n+ *best_partition_dualplane = (separate_best_component << PARTITION_BITS) |\n+ (separate_best_partition);\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "// Compile-time tuning parameters\nstatic const int TUNE_MIN_TEXELS_MODE0_FASTPATH { 25 };\n+// A high default error value\n+static const float ERROR_CALC_DEFAULT { 1e30f };\n+\n// uncomment this macro to enable checking for inappropriate NaNs;\n// works on Linux only, and slows down encoding significantly.\n// #define DEBUG_CAPTURE_NAN\n@@ -774,17 +777,27 @@ void compute_partition_error_color_weightings(\nfloat4 error_weightings[4],\nfloat4 color_scalefactors[4]);\n-// function to find the best partitioning for a given block.\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+ *\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+ */\nvoid find_best_partitionings(\n- int partition_search_limit,\nconst block_size_descriptor* bsd,\n- int partition_count,\n- const imageblock* pb,\n+ const imageblock* blk,\nconst error_weight_block* ewb,\n- int* best_partitions_uncorrelated,\n- int* best_partitions_samechroma,\n- int* best_partitions_dual_weight_planes);\n+ int partition_count,\n+ int partition_search_limit,\n+ int* best_partition_uncorrelated,\n+ int* best_partition_samechroma,\n+ int* best_partition_dualplane);\n// use k-means clustering to compute a partition ordering for a block.\nvoid kmeans_compute_partition_ordering(\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Refactor find_best_partitionings() (#150) We now only ever use a single result from this function, so we can refactor to track the single best result as we go along instead of storing all results in an array that gets scanned after-the-fact.
61,745
15.09.2020 21:01:38
-3,600
8838bf67c30106dd18f0f46989ce188e3fd2432f
Fix missing merge on report utility
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_result_report.py", "new_path": "Test/astc_test_result_report.py", "diff": "@@ -235,9 +235,9 @@ def print_result_set(imageSet, quality, encoders, results, printHeader):\ndr = DeltaRecord(imageSet, quality, encoders, recordSet)\n- if first:\n+ if printHeader:\nprint(dr.get_full_row_header_csv())\n- first = False\n+ printHeader = False\nprint(dr.get_full_row_csv())\n@@ -260,7 +260,7 @@ def main():\nqualitySet = sorted(qualityTree.keys())\nfor qual in qualitySet:\n- encoderTree = qualityTree[quality]\n+ encoderTree = qualityTree[qual]\nencoderSet = sorted(encoderTree.keys())\nif len(encoderSet) > 1:\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix missing merge on report utility (#153)
61,745
18.09.2020 22:37:10
-3,600
c19a125f5c1cfbcca184ab250b37badcb4698d7e
Fix two component normal unpack documentation
[ { "change_type": "MODIFY", "old_path": "Docs/Encoding.md", "new_path": "Docs/Encoding.md", "diff": "@@ -159,9 +159,10 @@ To encode this we therefore want to store two input channels and should\ntherefore use the `rrrg` coding swizzle, and the `.ga` sampling swizzle. The\nOpenGL ES shader code for reconstruction of the Z value is:\n- vec3 normal;\n- normal.xy = texture(...).ga;\n- normal.z = sqrt(1 - dot(normal.xy, normal.xy));\n+ vec3 nml;\n+ nml.xy = texture(...).ga; // Load normals (range 0 to 1)\n+ nml.xy = nml.xy * 2.0f - 1.0f; // Unpack normals (range -1 to +1)\n+ nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z, given unit length\nIn addition to this it is useful to optimize for angular error in the resulting\nvector rather than for absolute color error in the data, which improves the\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix two component normal unpack documentation (#154)
61,745
18.09.2020 22:41:37
-3,600
8607fdb591046e41299cbbceea3a9cb02048bf1b
Omit float literal qualifier in shader code sample
[ { "change_type": "MODIFY", "old_path": "Docs/Encoding.md", "new_path": "Docs/Encoding.md", "diff": "@@ -161,7 +161,7 @@ OpenGL ES shader code for reconstruction of the Z value is:\nvec3 nml;\nnml.xy = texture(...).ga; // Load normals (range 0 to 1)\n- nml.xy = nml.xy * 2.0f - 1.0f; // Unpack normals (range -1 to +1)\n+ nml.xy = nml.xy * 2.0 - 1.0; // Unpack normals (range -1 to +1)\nnml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z, given unit length\nIn addition to this it is useful to optimize for angular error in the resulting\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Omit float literal qualifier in shader code sample
61,750
23.09.2020 15:50:14
-3,600
478df21c62c0fb8b8e18e4226a16ced0e2935aeb
Remove Artifactory promote
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -177,7 +177,6 @@ pipeline {\nsteps {\nzip zipFile: 'astcenc.zip', dir: 'upload', archive: false\ncepeArtifactoryUpload(sourcePattern: '*.zip')\n- cepeArtifactoryPromote()\n}\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
QE-2134: Remove Artifactory promote (#156)
61,745
25.09.2020 21:39:47
-3,600
3a1fea973f17c2db4a8f775d6ec40b2ef6185792
Append to CXX flags
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -97,9 +97,11 @@ OBJECTS = $(SOURCES:.cpp=-$(BINARY).o)\nEXTERNAL_OBJECTS = $(EXTERNAL_SOURCES:.h=-$(BINARY).o)\n# ==================================================\n-# CXXFLAGS setup (and input validation)\n+# CXXFLAGS setup (and input validation). This appends on top of whatever\n+# CXXFLAGS are set on the command line, which is useful for integration\n+# with the oss-fuzz build infrastructure for fuzz testing\n-CXXFLAGS = -std=c++14 -fvisibility=hidden \\\n+CXXFLAGS += -std=c++14 -fvisibility=hidden \\\n-Wall -Wextra -Wpedantic -Werror -Werror=shadow -Wdouble-promotion\n# Validate that the APP parameter is a supported value, and patch CXXFLAGS\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Append to CXX flags (#157)
61,745
25.09.2020 23:33:31
-3,600
d38f6a509d6ca74598087e8a8f91f22d07a85293
Add in-tree fuzz target proof-of-concept Add in-tree fuzz target proof-of-concept for oss-fuzz
[ { "change_type": "MODIFY", "old_path": ".gitattributes", "new_path": ".gitattributes", "diff": "# Explicitly declare text file types for this repo\n*.c text\n-*.pp text\n+*.cpp text\n*.h text\n*.md text\nJenkinsfile text\n-# VS solution always use Windows line endings\n+# VS solutions always use Windows line endings\n*.sln text eol=crlf\n*.vcxproj text eol=crlf\n+# Bash scripts always use *nux line endings\n+*.sh text eol=lf\n+\n# Denote all files that are truly binary and should not be modified.\n*.png binary\n*.hdr binary\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Source/Fuzzers/build.sh", "diff": "+#!/bin/bash -eu\n+\n+# SPDX-License-Identifier: Apache-2.0\n+# ----------------------------------------------------------------------------\n+# Copyright 2020 Arm Limited\n+# Copyright 2020 Google Inc.\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+# Build the core project\n+make -j$(nproc) BUILD=debug VEC=sse2\n+\n+# Package up a library for fuzzers to link against\n+ar -qc libastcenc.a *.o\n+\n+# Build project local fuzzers\n+for fuzzer in $SRC/astc-encoder/Source/Fuzzers/fuzz_*.cpp; do\n+ $CXX $CXXFLAGS \\\n+ -DASTCENC_SSE=0 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0 -DASTCENC_VECALIGN=16 \\\n+ -I. -std=c++14 $fuzzer $LIB_FUZZING_ENGINE $SRC/astc-encoder/Source/libastcenc.a \\\n+ -o $OUT/$(basename -s .cpp $fuzzer)\n+done\n" }, { "change_type": "ADD", "old_path": null, "new_path": "Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp", "diff": "+// SPDX-License-Identifier: Apache-2.0\n+// ----------------------------------------------------------------------------\n+// Copyright 2020 Arm Limited\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+// use this file except in compliance with the License. You may obtain a copy\n+// of the License at:\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+// License for the specific language governing permissions and limitations\n+// under the License.\n+// ----------------------------------------------------------------------------\n+\n+/**\n+ * @brief Fuzz target for physical_to_symbolic().\n+ *\n+ * This function is the first entrypoint for decompressing a 16 byte block of\n+ * input ASTC data from disk. The 16 bytes can contain arbitrary data; they\n+ * are read from an external source, but the block size used must be a valid\n+ * ASTC block footprint.\n+ */\n+\n+\n+#include \"astcenc_internal.h\"\n+\n+#include <fuzzer/FuzzedDataProvider.h>\n+#include <array>\n+#include <vector>\n+\n+struct BlockSizes {\n+ int x;\n+ int y;\n+ int z;\n+};\n+\n+std::array<BlockSizes, 3> testSz {{\n+ { 4, 4, 1}, // Highest bitrate\n+ {12, 12, 1}, // Largest 2D block\n+ {6, 6, 6} // Largest 3D block\n+}};\n+\n+std::array<block_size_descriptor, 3> testBSD;\n+\n+/**\n+ * @brief Utility function to create all of the block size descriptors needed.\n+ *\n+ * This is triggered once via a static initializer.\n+ *\n+ * Triggering once is important so that we only create a single BSD per block\n+ * size we need, rather than one per fuzzer iteration (it's expensive). This\n+ * improves fuzzer throughput by ~ 1000x!\n+ *\n+ * Triggering via a static initializer, rather than a lazy init in the fuzzer\n+ * function, is important because is means that the BSD is allocated before\n+ * fuzzing starts. This means that leaksanitizer will ignore the fact that we\n+ * \"leak\" the dynamic allocations inside the BSD (we never call term()).\n+ */\n+bool bsd_initializer()\n+{\n+ for (int i = 0; i < testSz.size(); i++)\n+ {\n+ init_block_size_descriptor(\n+ testSz[i].x,\n+ testSz[i].y,\n+ testSz[i].z,\n+ &(testBSD[i]));\n+ }\n+\n+ return true;\n+}\n+\n+extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n+{\n+ // Preinitialize the block size descriptors we need\n+ static bool init = bsd_initializer();\n+\n+ // Must have 4 (select block size) and 16 (payload) bytes\n+ if (size < 4 + 16)\n+ {\n+ return 0;\n+ }\n+\n+ FuzzedDataProvider stream(data, size);\n+\n+ // Select a block size to test\n+ int i = stream.ConsumeIntegralInRange<int>(0, testSz.size() - 1);\n+ block_size_descriptor* bsd = &(testBSD[i]);\n+\n+ // Populate the physical block\n+ physical_compressed_block pcb;\n+ std::vector<uint8_t> buffer = stream.ConsumeBytes<uint8_t>(16);\n+ std::memcpy(&pcb, buffer.data(), 16);\n+\n+ // Call the function under test\n+ symbolic_compressed_block scb;\n+ physical_to_symbolic(bsd, pcb, &scb);\n+\n+ return 0;\n+}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add in-tree fuzz target proof-of-concept (#158) Add in-tree fuzz target proof-of-concept for oss-fuzz
61,750
05.10.2020 15:45:38
-3,600
dc715f12a1dbcc75ae1cf5dc1d4d4e255ba91d05
Update Jenkins shared libs for Artifactory Housekeeping job
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "-@Library('hive-infra-library@changes/18/246018/1') _\n+@Library('hive-infra-library@changes/91/265891/1') _\npipeline {\nagent none\n" }, { "change_type": "MODIFY", "old_path": "jenkins/dockerimage.Jenkinsfile", "new_path": "jenkins/dockerimage.Jenkinsfile", "diff": "-@Library('hive-infra-library@changes/18/246018/1') _\n+@Library('hive-infra-library@master') _\ndockerBuildImage('jenkins/build.Dockerfile', 'astcenc')\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
QE-2141: Update Jenkins shared libs for Artifactory Housekeeping job (#159)
61,745
06.10.2020 22:46:52
-3,600
6174fc8761bc671816caf6ef8dc279f09271d3fa
Cleanup sym_to_phy and phy_to_sym Pass by reference for singular values (mostly so we can distinguish singletons and arrays in code reviews). Pass PCB by ref rather than relying on write elision. Add some missing statics for module local functions
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1204,6 +1204,9 @@ void compress_symbolic_block(\nscb->constant_color[3] = astc::flt2int_rtn(alpha * 65535.0f);\n}\n+ physical_compressed_block pcb;\n+ symbolic_to_physical(*bsd, *scb, pcb);\n+ physical_to_symbolic(*bsd, pcb, *scb);\nreturn;\n}\n@@ -1447,7 +1450,6 @@ void compress_symbolic_block(\n}\n}\n-\n// Modes 7, 10 (13 is unreachable)\nbest_errorvals_in_modes[3 * (partition_count - 2) + 5 + 2] = best_errorval_in_mode;\n@@ -1460,8 +1462,9 @@ void compress_symbolic_block(\nEND_OF_TESTS:\n// compress/decompress to a physical block\n- physical_compressed_block psb = symbolic_to_physical(bsd, scb);\n- physical_to_symbolic(bsd, psb, scb);\n+ physical_compressed_block pcb;\n+ symbolic_to_physical(*bsd, *scb, pcb);\n+ physical_to_symbolic(*bsd, pcb, *scb);\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -598,12 +598,15 @@ static void compress_image(\nint x = rem - (y * row_blocks);\n// Decompress\n- int offset = ((z * yblocks + y) * xblocks + x) * 16;\n- const uint8_t *bp = buffer + offset;\nfetch_imageblock(decode_mode, image, &pb, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n+\nsymbolic_compressed_block scb;\ncompress_symbolic_block(ctx, image, decode_mode, bsd, &pb, &scb, temp_buffers);\n- *(physical_compressed_block*) bp = symbolic_to_physical(bsd, &scb);\n+\n+ int offset = ((z * yblocks + y) * xblocks + x) * 16;\n+ uint8_t *bp = buffer + offset;\n+ physical_compressed_block* pcb = reinterpret_cast<physical_compressed_block*>(bp);\n+ symbolic_to_physical(*bsd, scb, *pcb);\n}\nctx.manage_compress.complete_task_assignment(count);\n@@ -773,10 +776,13 @@ astcenc_error astcenc_decompress_image(\nconst uint8_t* bp = data + offset;\nphysical_compressed_block pcb = *(physical_compressed_block *) bp;\nsymbolic_compressed_block scb;\n- physical_to_symbolic(context->bsd, pcb, &scb);\n+\n+ physical_to_symbolic(*context->bsd, pcb, scb);\n+\ndecompress_symbolic_block(context->config.profile, context->bsd,\nx * block_x, y * block_y, z * block_z,\n&scb, &pb);\n+\nwrite_imageblock(image_out, &pb, context->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": "#include \"astcenc_internal.h\"\n// conversion functions between the LNS representation and the FP16 representation.\n-float float_to_lns(float p)\n+static float float_to_lns(float p)\n{\nif (astc::isnan(p) || p <= 1.0f / 67108864.0f)\n{\n@@ -66,7 +66,7 @@ float float_to_lns(float p)\nreturn p1 + 1.0f;\n}\n-uint16_t lns_to_sf16(uint16_t p)\n+static uint16_t lns_to_sf16(uint16_t p)\n{\nuint16_t mc = p & 0x7FF;\nuint16_t ec = p >> 11;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_integer_sequence.cpp", "new_path": "Source/astcenc_integer_sequence.cpp", "diff": "@@ -329,7 +329,7 @@ static const uint8_t integer_of_trits[3][3][3][3][3] = {\n}\n};\n-void find_number_of_bits_trits_quints(\n+static void find_number_of_bits_trits_quints(\nint quantization_level,\nint* bits,\nint* trits,\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1125,22 +1125,19 @@ void decompress_symbolic_block(\nconst symbolic_compressed_block* scb,\nimageblock* blk);\n-physical_compressed_block symbolic_to_physical(\n- const block_size_descriptor* bsd,\n- const symbolic_compressed_block* sc);\n+void symbolic_to_physical(\n+ const block_size_descriptor& bsd,\n+ const symbolic_compressed_block& scb,\n+ physical_compressed_block& pcb);\nvoid physical_to_symbolic(\n- const block_size_descriptor* bsd,\n- physical_compressed_block pb,\n- symbolic_compressed_block* res);\n+ const block_size_descriptor& bsd,\n+ const physical_compressed_block& pcb,\n+ symbolic_compressed_block& scb);\nuint16_t unorm16_to_sf16(\nuint16_t p);\n-uint16_t lns_to_sf16(\n- uint16_t p);\n-\n-\nstruct astcenc_context\n{\nastcenc_config config;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_symbolic_physical.cpp", "new_path": "Source/astcenc_symbolic_physical.cpp", "diff": "@@ -65,13 +65,12 @@ static inline int bitrev8(int p)\nreturn p;\n}\n-physical_compressed_block symbolic_to_physical(\n- const block_size_descriptor* bsd,\n- const symbolic_compressed_block* sc\n+void symbolic_to_physical(\n+ const block_size_descriptor& bsd,\n+ const symbolic_compressed_block& scb,\n+ physical_compressed_block& pcb\n) {\n- physical_compressed_block res;\n-\n- if (sc->block_mode == -2)\n+ if (scb.block_mode == -2)\n{\n// UNORM16 constant-color block.\n// This encodes separate constant-color blocks. There is currently\n@@ -80,19 +79,19 @@ physical_compressed_block symbolic_to_physical(\nstatic const uint8_t cbytes[8] = { 0xFC, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\nfor (int i = 0; i < 8; i++)\n{\n- res.data[i] = cbytes[i];\n+ pcb.data[i] = cbytes[i];\n}\nfor (int i = 0; i < 4; i++)\n{\n- res.data[2 * i + 8] = sc->constant_color[i] & 0xFF;\n- res.data[2 * i + 9] = (sc->constant_color[i] >> 8) & 0xFF;\n+ pcb.data[2 * i + 8] = scb.constant_color[i] & 0xFF;\n+ pcb.data[2 * i + 9] = (scb.constant_color[i] >> 8) & 0xFF;\n}\n- return res;\n+ return;\n}\n- if (sc->block_mode == -1)\n+ if (scb.block_mode == -1)\n{\n// FP16 constant-color block.\n// This encodes separate constant-color blocks. There is currently\n@@ -101,19 +100,19 @@ physical_compressed_block symbolic_to_physical(\nstatic const uint8_t cbytes[8] = { 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };\nfor (int i = 0; i < 8; i++)\n{\n- res.data[i] = cbytes[i];\n+ pcb.data[i] = cbytes[i];\n}\nfor (int i = 0; i < 4; i++)\n{\n- res.data[2 * i + 8] = sc->constant_color[i] & 0xFF;\n- res.data[2 * i + 9] = (sc->constant_color[i] >> 8) & 0xFF;\n+ pcb.data[2 * i + 8] = scb.constant_color[i] & 0xFF;\n+ pcb.data[2 * i + 9] = (scb.constant_color[i] >> 8) & 0xFF;\n}\n- return res;\n+ return;\n}\n- int partition_count = sc->partition_count;\n+ int partition_count = scb.partition_count;\n// first, compress the weights. They are encoded as an ordinary\n// integer-sequence, then bit-reversed\n@@ -123,11 +122,11 @@ physical_compressed_block symbolic_to_physical(\nweightbuf[i] = 0;\n}\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n+ const decimation_table *const *ixtab2 = bsd.decimation_tables;\n- int weight_count = ixtab2[bsd->block_modes[sc->block_mode].decimation_mode]->num_weights;\n- int weight_quantization_method = bsd->block_modes[sc->block_mode].quantization_mode;\n- int is_dual_plane = bsd->block_modes[sc->block_mode].is_dual_plane;\n+ int weight_count = ixtab2[bsd.block_modes[scb.block_mode].decimation_mode]->num_weights;\n+ int weight_quantization_method = bsd.block_modes[scb.block_mode].quantization_mode;\n+ int is_dual_plane = bsd.block_modes[scb.block_mode].is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n@@ -139,23 +138,23 @@ physical_compressed_block symbolic_to_physical(\nuint8_t weights[64];\nfor (int i = 0; i < weight_count; i++)\n{\n- weights[2 * i] = sc->plane1_weights[i];\n- weights[2 * i + 1] = sc->plane2_weights[i];\n+ weights[2 * i] = scb.plane1_weights[i];\n+ weights[2 * i + 1] = scb.plane2_weights[i];\n}\nencode_ise(weight_quantization_method, real_weight_count, weights, weightbuf, 0);\n}\nelse\n{\n- encode_ise(weight_quantization_method, weight_count, sc->plane1_weights, weightbuf, 0);\n+ encode_ise(weight_quantization_method, weight_count, scb.plane1_weights, weightbuf, 0);\n}\nfor (int i = 0; i < 16; i++)\n{\n- res.data[i] = bitrev8(weightbuf[15 - i]);\n+ pcb.data[i] = bitrev8(weightbuf[15 - i]);\n}\n- write_bits(sc->block_mode, 11, 0, res.data);\n- write_bits(partition_count - 1, 2, 11, res.data);\n+ write_bits(scb.block_mode, 11, 0, pcb.data);\n+ write_bits(partition_count - 1, 2, 11, pcb.data);\nint below_weights_pos = 128 - bits_for_weights;\n@@ -163,12 +162,12 @@ physical_compressed_block symbolic_to_physical(\n// 2 or more partitions.\nif (partition_count > 1)\n{\n- write_bits(sc->partition_index, 6, 13, res.data);\n- write_bits(sc->partition_index >> 6, PARTITION_BITS - 6, 19, res.data);\n+ write_bits(scb.partition_index, 6, 13, pcb.data);\n+ write_bits(scb.partition_index >> 6, PARTITION_BITS - 6, 19, pcb.data);\n- if (sc->color_formats_matched)\n+ if (scb.color_formats_matched)\n{\n- write_bits(sc->color_formats[0] << 2, 6, 13 + PARTITION_BITS, res.data);\n+ write_bits(scb.color_formats[0] << 2, 6, 13 + PARTITION_BITS, pcb.data);\n}\nelse\n{\n@@ -178,7 +177,7 @@ physical_compressed_block symbolic_to_physical(\nfor (int i = 0; i < partition_count; i++)\n{\n- int class_of_format = sc->color_formats[i] >> 2;\n+ int class_of_format = scb.color_formats[i] >> 2;\nif (class_of_format < low_class)\n{\nlow_class = class_of_format;\n@@ -195,14 +194,14 @@ physical_compressed_block symbolic_to_physical(\nfor (int i = 0; i < partition_count; i++)\n{\n- int classbit_of_format = (sc->color_formats[i] >> 2) - low_class;\n+ int classbit_of_format = (scb.color_formats[i] >> 2) - low_class;\nencoded_type |= classbit_of_format << bitpos;\nbitpos++;\n}\nfor (int i = 0; i < partition_count; i++)\n{\n- int lowbits_of_format = sc->color_formats[i] & 3;\n+ int lowbits_of_format = scb.color_formats[i] & 3;\nencoded_type |= lowbits_of_format << bitpos;\nbitpos += 2;\n}\n@@ -211,56 +210,54 @@ physical_compressed_block symbolic_to_physical(\nint encoded_type_highpart = encoded_type >> 6;\nint encoded_type_highpart_size = (3 * partition_count) - 4;\nint encoded_type_highpart_pos = 128 - bits_for_weights - encoded_type_highpart_size;\n- write_bits(encoded_type_lowpart, 6, 13 + PARTITION_BITS, res.data);\n- write_bits(encoded_type_highpart, encoded_type_highpart_size, encoded_type_highpart_pos, res.data);\n+ write_bits(encoded_type_lowpart, 6, 13 + PARTITION_BITS, pcb.data);\n+ write_bits(encoded_type_highpart, encoded_type_highpart_size, encoded_type_highpart_pos, pcb.data);\nbelow_weights_pos -= encoded_type_highpart_size;\n}\n}\nelse\n{\n- write_bits(sc->color_formats[0], 4, 13, res.data);\n+ write_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\nif (is_dual_plane)\n{\n- write_bits(sc->plane2_color_component, 2, below_weights_pos - 2, res.data);\n+ write_bits(scb.plane2_color_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\nuint8_t values_to_encode[32];\nint valuecount_to_encode = 0;\n- for (int i = 0; i < sc->partition_count; i++)\n+ for (int i = 0; i < scb.partition_count; i++)\n{\n- int vals = 2 * (sc->color_formats[i] >> 2) + 2;\n+ int vals = 2 * (scb.color_formats[i] >> 2) + 2;\nfor (int j = 0; j < vals; j++)\n{\n- values_to_encode[j + valuecount_to_encode] = sc->color_values[i][j];\n+ values_to_encode[j + valuecount_to_encode] = scb.color_values[i][j];\n}\nvaluecount_to_encode += vals;\n}\n// then, encode an ISE based on them.\n- encode_ise(sc->color_quantization_level, valuecount_to_encode, values_to_encode, res.data, (sc->partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n-\n- return res;\n+ encode_ise(scb.color_quantization_level, valuecount_to_encode, values_to_encode, pcb.data, (scb.partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n}\nvoid physical_to_symbolic(\n- const block_size_descriptor* bsd,\n- physical_compressed_block pb,\n- symbolic_compressed_block* res\n+ const block_size_descriptor& bsd,\n+ const physical_compressed_block& pcb,\n+ symbolic_compressed_block& scb\n) {\nuint8_t bswapped[16];\n- res->error_block = 0;\n+ scb.error_block = 0;\n// get hold of the decimation tables.\n- const decimation_table *const *ixtab2 = bsd->decimation_tables;\n+ const decimation_table *const *ixtab2 = bsd.decimation_tables;\n// extract header fields\n- int block_mode = read_bits(11, 0, pb.data);\n+ int block_mode = read_bits(11, 0, pcb.data);\nif ((block_mode & 0x1FF) == 0x1FC)\n{\n// void-extent block!\n@@ -268,82 +265,82 @@ void physical_to_symbolic(\n// check what format the data has\nif (block_mode & 0x200)\n{\n- res->block_mode = -1; // floating-point\n+ scb.block_mode = -1; // floating-point\n}\nelse\n{\n- res->block_mode = -2; // unorm16.\n+ scb.block_mode = -2; // unorm16.\n}\n- res->partition_count = 0;\n+ scb.partition_count = 0;\nfor (int i = 0; i < 4; i++)\n{\n- res->constant_color[i] = pb.data[2 * i + 8] | (pb.data[2 * i + 9] << 8);\n+ scb.constant_color[i] = pcb.data[2 * i + 8] | (pcb.data[2 * i + 9] << 8);\n}\n// additionally, check that the void-extent\n- if (bsd->zdim == 1)\n+ if (bsd.zdim == 1)\n{\n// 2D void-extent\n- int rsvbits = read_bits(2, 10, pb.data);\n+ int rsvbits = read_bits(2, 10, pcb.data);\nif (rsvbits != 3)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\n}\n- int vx_low_s = read_bits(8, 12, pb.data) | (read_bits(5, 12 + 8, pb.data) << 8);\n- int vx_high_s = read_bits(8, 25, pb.data) | (read_bits(5, 25 + 8, pb.data) << 8);\n- int vx_low_t = read_bits(8, 38, pb.data) | (read_bits(5, 38 + 8, pb.data) << 8);\n- int vx_high_t = read_bits(8, 51, pb.data) | (read_bits(5, 51 + 8, pb.data) << 8);\n+ int vx_low_s = read_bits(8, 12, pcb.data) | (read_bits(5, 12 + 8, pcb.data) << 8);\n+ int vx_high_s = read_bits(8, 25, pcb.data) | (read_bits(5, 25 + 8, pcb.data) << 8);\n+ int vx_low_t = read_bits(8, 38, pcb.data) | (read_bits(5, 38 + 8, pcb.data) << 8);\n+ int vx_high_t = read_bits(8, 51, pcb.data) | (read_bits(5, 51 + 8, pcb.data) << 8);\nint all_ones = vx_low_s == 0x1FFF && vx_high_s == 0x1FFF && vx_low_t == 0x1FFF && vx_high_t == 0x1FFF;\nif ((vx_low_s >= vx_high_s || vx_low_t >= vx_high_t) && !all_ones)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\n}\n}\nelse\n{\n// 3D void-extent\n- int vx_low_s = read_bits(9, 10, pb.data);\n- int vx_high_s = read_bits(9, 19, pb.data);\n- int vx_low_t = read_bits(9, 28, pb.data);\n- int vx_high_t = read_bits(9, 37, pb.data);\n- int vx_low_p = read_bits(9, 46, pb.data);\n- int vx_high_p = read_bits(9, 55, pb.data);\n+ int vx_low_s = read_bits(9, 10, pcb.data);\n+ int vx_high_s = read_bits(9, 19, pcb.data);\n+ int vx_low_t = read_bits(9, 28, pcb.data);\n+ int vx_high_t = read_bits(9, 37, pcb.data);\n+ int vx_low_p = read_bits(9, 46, pcb.data);\n+ int vx_high_p = read_bits(9, 55, pcb.data);\nint all_ones = vx_low_s == 0x1FF && vx_high_s == 0x1FF && vx_low_t == 0x1FF && vx_high_t == 0x1FF && vx_low_p == 0x1FF && vx_high_p == 0x1FF;\nif ((vx_low_s >= vx_high_s || vx_low_t >= vx_high_t || vx_low_p >= vx_high_p) && !all_ones)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\n}\n}\nreturn;\n}\n- if (bsd->block_modes[block_mode].permit_decode == 0)\n+ if (bsd.block_modes[block_mode].permit_decode == 0)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\nreturn;\n}\n- int weight_count = ixtab2[bsd->block_modes[block_mode].decimation_mode]->num_weights;\n- int weight_quantization_method = bsd->block_modes[block_mode].quantization_mode;\n- int is_dual_plane = bsd->block_modes[block_mode].is_dual_plane;\n+ int weight_count = ixtab2[bsd.block_modes[block_mode].decimation_mode]->num_weights;\n+ int weight_quantization_method = bsd.block_modes[block_mode].quantization_mode;\n+ int is_dual_plane = bsd.block_modes[block_mode].is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n- int partition_count = read_bits(2, 11, pb.data) + 1;\n+ int partition_count = read_bits(2, 11, pcb.data) + 1;\n- res->block_mode = block_mode;\n- res->partition_count = partition_count;\n+ scb.block_mode = block_mode;\n+ scb.partition_count = partition_count;\nfor (int i = 0; i < 16; i++)\n{\n- bswapped[i] = bitrev8(pb.data[15 - i]);\n+ bswapped[i] = bitrev8(pcb.data[15 - i]);\n}\nint bits_for_weights = compute_ise_bitcount(real_weight_count,\n@@ -357,35 +354,35 @@ void physical_to_symbolic(\ndecode_ise(weight_quantization_method, real_weight_count, bswapped, indices, 0);\nfor (int i = 0; i < weight_count; i++)\n{\n- res->plane1_weights[i] = indices[2 * i];\n- res->plane2_weights[i] = indices[2 * i + 1];\n+ scb.plane1_weights[i] = indices[2 * i];\n+ scb.plane2_weights[i] = indices[2 * i + 1];\n}\n}\nelse\n{\n- decode_ise(weight_quantization_method, weight_count, bswapped, res->plane1_weights, 0);\n+ decode_ise(weight_quantization_method, weight_count, bswapped, scb.plane1_weights, 0);\n}\nif (is_dual_plane && partition_count == 4)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\n}\n- res->color_formats_matched = 0;\n+ scb.color_formats_matched = 0;\n// then, determine the format of each endpoint pair\nint color_formats[4];\nint encoded_type_highpart_size = 0;\nif (partition_count == 1)\n{\n- color_formats[0] = read_bits(4, 13, pb.data);\n- res->partition_index = 0;\n+ color_formats[0] = read_bits(4, 13, pcb.data);\n+ scb.partition_index = 0;\n}\nelse\n{\nencoded_type_highpart_size = (3 * partition_count) - 4;\nbelow_weights_pos -= encoded_type_highpart_size;\n- int encoded_type = read_bits(6, 13 + PARTITION_BITS, pb.data) | (read_bits(encoded_type_highpart_size, below_weights_pos, pb.data) << 6);\n+ int encoded_type = read_bits(6, 13 + PARTITION_BITS, pcb.data) | (read_bits(encoded_type_highpart_size, below_weights_pos, pcb.data) << 6);\nint baseclass = encoded_type & 0x3;\nif (baseclass == 0)\n{\n@@ -395,7 +392,7 @@ void physical_to_symbolic(\n}\nbelow_weights_pos += encoded_type_highpart_size;\n- res->color_formats_matched = 1;\n+ scb.color_formats_matched = 1;\nencoded_type_highpart_size = 0;\n}\nelse\n@@ -415,12 +412,12 @@ void physical_to_symbolic(\nbitpos += 2;\n}\n}\n- res->partition_index = read_bits(6, 13, pb.data) | (read_bits(PARTITION_BITS - 6, 19, pb.data) << 6);\n+ scb.partition_index = read_bits(6, 13, pcb.data) | (read_bits(PARTITION_BITS - 6, 19, pcb.data) << 6);\n}\nfor (int i = 0; i < partition_count; i++)\n{\n- res->color_formats[i] = color_formats[i];\n+ scb.color_formats[i] = color_formats[i];\n}\n// then, determine the number of integers we need to unpack for the endpoint pairs\n@@ -433,7 +430,7 @@ void physical_to_symbolic(\nif (color_integer_count > 18)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\n}\n// then, determine the color endpoint format to use for these integers\n@@ -450,15 +447,15 @@ void physical_to_symbolic(\n}\nint color_quantization_level = quantization_mode_table[color_integer_count >> 1][color_bits];\n- res->color_quantization_level = color_quantization_level;\n+ scb.color_quantization_level = color_quantization_level;\nif (color_quantization_level < 4)\n{\n- res->error_block = 1;\n+ scb.error_block = 1;\n}\n// then unpack the integer-bits\nuint8_t values_to_decode[32];\n- decode_ise(color_quantization_level, color_integer_count, pb.data, values_to_decode, (partition_count == 1 ? 17 : 19 + PARTITION_BITS));\n+ decode_ise(color_quantization_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@@ -468,7 +465,7 @@ void physical_to_symbolic(\nint vals = 2 * (color_formats[i] >> 2) + 2;\nfor (int j = 0; j < vals; j++)\n{\n- res->color_values[i][j] = values_to_decode[j + valuecount_to_decode];\n+ scb.color_values[i][j] = values_to_decode[j + valuecount_to_decode];\n}\nvaluecount_to_decode += vals;\n}\n@@ -476,6 +473,6 @@ void physical_to_symbolic(\n// get hold of color component for second-plane in the case of dual plane of weights.\nif (is_dual_plane)\n{\n- res->plane2_color_component = read_bits(2, below_weights_pos - 2, pb.data);\n+ scb.plane2_color_component = read_bits(2, below_weights_pos - 2, pcb.data);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -314,7 +314,7 @@ static void compute_lowest_and_highest_weight(\n}\n// main function for running the angular algorithm.\n-void compute_angular_endpoints_for_quantization_levels(\n+static void compute_angular_endpoints_for_quantization_levels(\nint samplecount,\nconst float* samples,\nconst float* sample_weights,\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Cleanup sym_to_phy and phy_to_sym - Pass by reference for singular values (mostly so we can distinguish singletons and arrays in code reviews). - Pass PCB by ref rather than relying on write elision. - Add some missing statics for module local functions
61,745
06.10.2020 23:09:23
-3,600
226a6418614b74dbabc0ea7795d9c9ea41f02504
Avoid sym->phy->sym->phy on compression compress_symbolic_block renamed to compress_block function now returns both sym and phy in one pass
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1140,15 +1140,17 @@ static void prepare_block_statistics(\n*is_normal_map = nf_sum < (0.2f * (float)texels_per_block);\n}\n-void compress_symbolic_block(\n+void compress_block(\nconst astcenc_context& ctx,\nconst astcenc_image& input_image,\n- astcenc_profile decode_mode,\n- const block_size_descriptor* bsd,\nconst imageblock* blk,\n- symbolic_compressed_block* scb,\n+ symbolic_compressed_block& scb,\n+ physical_compressed_block& pcb,\ncompress_symbolic_block_buffers* tmpbuf)\n{\n+ astcenc_profile decode_mode = ctx.config.profile;\n+ const block_size_descriptor* bsd = ctx.bsd;\n+\nint xpos = blk->xpos;\nint ypos = blk->ypos;\nint zpos = blk->zpos;\n@@ -1156,23 +1158,23 @@ void compress_symbolic_block(\nif (blk->red_min == blk->red_max && blk->green_min == blk->green_max && blk->blue_min == blk->blue_max && blk->alpha_min == blk->alpha_max)\n{\n// detected a constant-color block. Encode as FP16 if using HDR\n- scb->error_block = 0;\n+ scb.error_block = 0;\nif ((decode_mode == ASTCENC_PRF_HDR) ||\n(decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A))\n{\n- scb->block_mode = -1;\n- scb->partition_count = 0;\n- scb->constant_color[0] = float_to_sf16(blk->orig_data[0], SF_NEARESTEVEN);\n- scb->constant_color[1] = float_to_sf16(blk->orig_data[1], SF_NEARESTEVEN);\n- scb->constant_color[2] = float_to_sf16(blk->orig_data[2], SF_NEARESTEVEN);\n- scb->constant_color[3] = float_to_sf16(blk->orig_data[3], SF_NEARESTEVEN);\n+ scb.block_mode = -1;\n+ scb.partition_count = 0;\n+ scb.constant_color[0] = float_to_sf16(blk->orig_data[0], SF_NEARESTEVEN);\n+ scb.constant_color[1] = float_to_sf16(blk->orig_data[1], SF_NEARESTEVEN);\n+ scb.constant_color[2] = float_to_sf16(blk->orig_data[2], SF_NEARESTEVEN);\n+ scb.constant_color[3] = float_to_sf16(blk->orig_data[3], SF_NEARESTEVEN);\n}\nelse\n{\n// Encode as UNORM16 if NOT using HDR.\n- scb->block_mode = -2;\n- scb->partition_count = 0;\n+ scb.block_mode = -2;\n+ scb.partition_count = 0;\nfloat red = blk->orig_data[0];\nfloat green = blk->orig_data[1];\nfloat blue = blk->orig_data[2];\n@@ -1198,15 +1200,13 @@ void compress_symbolic_block(\nelse if (alpha > 1)\nalpha = 1;\n- scb->constant_color[0] = astc::flt2int_rtn(red * 65535.0f);\n- scb->constant_color[1] = astc::flt2int_rtn(green * 65535.0f);\n- scb->constant_color[2] = astc::flt2int_rtn(blue * 65535.0f);\n- scb->constant_color[3] = astc::flt2int_rtn(alpha * 65535.0f);\n+ scb.constant_color[0] = astc::flt2int_rtn(red * 65535.0f);\n+ scb.constant_color[1] = astc::flt2int_rtn(green * 65535.0f);\n+ scb.constant_color[2] = astc::flt2int_rtn(blue * 65535.0f);\n+ scb.constant_color[3] = astc::flt2int_rtn(alpha * 65535.0f);\n}\n- physical_compressed_block pcb;\n- symbolic_to_physical(*bsd, *scb, pcb);\n- physical_to_symbolic(*bsd, pcb, *scb);\n+ symbolic_to_physical(*bsd, scb, pcb);\nreturn;\n}\n@@ -1272,7 +1272,7 @@ void compress_symbolic_block(\nif (errorval < error_of_best_block)\n{\nerror_of_best_block = errorval;\n- *scb = tempblocks[j];\n+ scb = tempblocks[j];\n}\n}\n@@ -1337,7 +1337,7 @@ void compress_symbolic_block(\nif (errorval < error_of_best_block)\n{\nerror_of_best_block = errorval;\n- *scb = tempblocks[j];\n+ scb = tempblocks[j];\n}\n// Modes 1-4\n@@ -1386,7 +1386,7 @@ void compress_symbolic_block(\nif (errorval < error_of_best_block)\n{\nerror_of_best_block = errorval;\n- *scb = tempblocks[j];\n+ scb = tempblocks[j];\n}\n}\n@@ -1446,7 +1446,7 @@ void compress_symbolic_block(\nif (errorval < error_of_best_block)\n{\nerror_of_best_block = errorval;\n- *scb = tempblocks[j];\n+ scb = tempblocks[j];\n}\n}\n@@ -1462,9 +1462,7 @@ void compress_symbolic_block(\nEND_OF_TESTS:\n// compress/decompress to a physical block\n- physical_compressed_block pcb;\n- symbolic_to_physical(*bsd, *scb, pcb);\n- physical_to_symbolic(*bsd, pcb, *scb);\n+ symbolic_to_physical(*bsd, scb, pcb);\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -600,13 +600,12 @@ static void compress_image(\n// Decompress\nfetch_imageblock(decode_mode, image, &pb, bsd, x * block_x, y * block_y, z * block_z, swizzle);\n- symbolic_compressed_block scb;\n- compress_symbolic_block(ctx, image, decode_mode, bsd, &pb, &scb, temp_buffers);\nint offset = ((z * yblocks + y) * xblocks + x) * 16;\nuint8_t *bp = buffer + offset;\nphysical_compressed_block* pcb = reinterpret_cast<physical_compressed_block*>(bp);\n- symbolic_to_physical(*bsd, scb, *pcb);\n+ symbolic_compressed_block scb;\n+ compress_block(ctx, image, &pb, scb, *pcb, temp_buffers);\n}\nctx.manage_compress.complete_task_assignment(count);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -1107,13 +1107,12 @@ void compute_angular_endpoints_2planes(\n/* *********************************** high-level encode and decode functions ************************************ */\n-void compress_symbolic_block(\n+void compress_block(\nconst astcenc_context& ctx,\nconst astcenc_image& image,\n- astcenc_profile decode_mode,\n- const block_size_descriptor* bsd,\nconst imageblock* blk,\n- symbolic_compressed_block* scb,\n+ symbolic_compressed_block& scb,\n+ physical_compressed_block& pcb,\ncompress_symbolic_block_buffers* tmpbuf);\nvoid decompress_symbolic_block(\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Avoid sym->phy->sym->phy on compression - compress_symbolic_block renamed to compress_block - function now returns both sym and phy in one pass
61,745
07.10.2020 23:27:04
-3,600
ab16aaabe4402361a12c7553c817519ed65fc31e
Implement support for F32 as core API channel type Code to use this for HDR images is also implemented for the CLI wrapper, but currently the HDR functionality in the wrapper is still routed though FP16. Local testing indicates that this works as expected.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -216,9 +216,8 @@ static void compute_pixel_region_variance(\n}\n}\n}\n- else //if (img->data_type == ASTCENC_TYPE_F16)\n+ else if (img->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img->data);\n// Swizzle data structure 4 = ZERO, 5 = ONE (in FP16)\n@@ -265,6 +264,52 @@ static void compute_pixel_region_variance(\n}\n}\n}\n+ else // if (img->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img->data);\n+\n+ // Swizzle data structure 4 = ZERO, 5 = ONE (in FP16)\n+ float data[6];\n+ data[ASTCENC_SWZ_0] = 0.0f;\n+ data[ASTCENC_SWZ_1] = 1.0f;\n+\n+ for (int z = zd_start; z < padsize_z; z++)\n+ {\n+ int z_src = (z - zd_start) + src_offset_z - kernel_radius_z;\n+\n+ for (int y = 1; y < padsize_y; y++)\n+ {\n+ int y_src = (y - 1) + src_offset_y - kernel_radius_xy;\n+ for (int x = 1; x < padsize_x; x++)\n+ {\n+ int x_src = (x - 1) + src_offset_x - kernel_radius_xy;\n+ data[0] = data32[z_src][y_src][4 * x_src ];\n+ data[1] = data32[z_src][y_src][4 * x_src + 1];\n+ data[2] = data32[z_src][y_src][4 * x_src + 2];\n+ data[3] = data32[z_src][y_src][4 * x_src + 3];\n+\n+ float r = data[swz.r];\n+ float g = data[swz.g];\n+ float b = data[swz.b];\n+ float a = data[swz.a];\n+\n+ float4 d = float4(r, g, b, a);\n+\n+ if (!are_powers_1)\n+ {\n+ d.x = powf(MAX(d.x, 1e-6f), rgb_power);\n+ d.y = powf(MAX(d.y, 1e-6f), rgb_power);\n+ d.z = powf(MAX(d.z, 1e-6f), rgb_power);\n+ d.w = powf(MAX(d.w, 1e-6f), alpha_power);\n+ }\n+\n+ VARBUF1(z, y, x) = d;\n+ VARBUF2(z, y, x) = d * d;\n+ }\n+ }\n+ }\n+ }\n// Pad with an extra layer of 0s; this forms the edge of the SAT tables\nfloat4 vbz = float4(0.0f, 0.0f, 0.0f, 0.0f);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -337,9 +337,8 @@ void fetch_imageblock(\n}\n}\n}\n- else // if (img.data_type == ASTCENC_TYPE_F16)\n+ else if (img.data_type == ASTCENC_TYPE_F16)\n{\n- assert(img.data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img.data);\nfor (int z = 0; z < bsd->zdim; z++)\n{\n@@ -394,6 +393,53 @@ void fetch_imageblock(\n}\n}\n}\n+ else // if (img.data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img.data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img.data);\n+ for (int z = 0; z < bsd->zdim; z++)\n+ {\n+ for (int y = 0; y < bsd->ydim; y++)\n+ {\n+ for (int x = 0; x < bsd->xdim; x++)\n+ {\n+ int xi = xpos + x;\n+ int yi = ypos + y;\n+ int zi = zpos + z;\n+ // clamp XY coordinates to the picture.\n+ if (xi < 0)\n+ xi = 0;\n+ if (yi < 0)\n+ yi = 0;\n+ if (zi < 0)\n+ zi = 0;\n+ if (xi >= xsize)\n+ xi = xsize - 1;\n+ if (yi >= ysize)\n+ yi = ysize - 1;\n+ if (zi >= ysize)\n+ zi = zsize - 1;\n+\n+ float r = data32[zi][yi][4 * xi ];\n+ float g = data32[zi][yi][4 * xi + 1];\n+ float b = data32[zi][yi][4 * xi + 2];\n+ float a = data32[zi][yi][4 * xi + 3];\n+\n+ // equalize the color components somewhat, and get rid of negative values.\n+ data[0] = MAX(r, 1e-8f);\n+ data[1] = MAX(g, 1e-8f);\n+ data[2] = MAX(b, 1e-8f);\n+ data[3] = MAX(a, 1e-8f);\n+\n+ fptr[0] = data[swz.r];\n+ fptr[1] = data[swz.g];\n+ fptr[2] = data[swz.b];\n+ fptr[3] = data[swz.a];\n+ fptr += 4;\n+ }\n+ }\n+ }\n+ }\nint rgb_lns = (decode_mode == ASTCENC_PRF_HDR) || (decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A);\nint alpha_lns = decode_mode == ASTCENC_PRF_HDR;\n@@ -508,9 +554,8 @@ void write_imageblock(\n}\n}\n}\n- else // if (img.data_type == ASTCENC_TYPE_F16)\n+ else if (img.data_type == ASTCENC_TYPE_F16)\n{\n- assert(img.data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img.data);\nfor (int z = 0; z < bsd->zdim; z++)\n{\n@@ -531,7 +576,6 @@ void write_imageblock(\ndata16[zi][yi][4 * xi + 2] = 0xFFFF;\ndata16[zi][yi][4 * xi + 3] = 0xFFFF;\n}\n-\nelse\n{\ndata[0] = fptr[0];\n@@ -564,6 +608,57 @@ void write_imageblock(\n}\n}\n}\n+ else // if (img.data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img.data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img.data);\n+ for (int z = 0; z < bsd->zdim; z++)\n+ {\n+ for (int y = 0; y < bsd->ydim; y++)\n+ {\n+ for (int x = 0; x < bsd->xdim; x++)\n+ {\n+ int xi = xpos + x;\n+ int yi = ypos + y;\n+ int zi = zpos + z;\n+\n+ if (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n+ {\n+ if (*nptr)\n+ {\n+ data32[zi][yi][4 * xi] = std::numeric_limits<float>::quiet_NaN();\n+ data32[zi][yi][4 * xi + 1] = std::numeric_limits<float>::quiet_NaN();\n+ data32[zi][yi][4 * xi + 2] = std::numeric_limits<float>::quiet_NaN();\n+ data32[zi][yi][4 * xi + 3] = std::numeric_limits<float>::quiet_NaN();\n+ }\n+ else\n+ {\n+ data[0] = fptr[0];\n+ data[1] = fptr[1];\n+ data[2] = fptr[2];\n+ data[3] = fptr[3];\n+\n+ float xN = (data[0] * 2.0f) - 1.0f;\n+ float yN = (data[3] * 2.0f) - 1.0f;\n+ float zN = 1.0f - xN * xN - yN * yN;\n+ if (zN < 0.0f)\n+ {\n+ zN = 0.0f;\n+ }\n+ data[6] = (astc::sqrt(zN) * 0.5f) + 0.5f;\n+\n+ data32[zi][yi][4 * xi] = data[swz.r];\n+ data32[zi][yi][4 * xi + 1] = data[swz.g];\n+ data32[zi][yi][4 * xi + 2] = data[swz.b];\n+ data32[zi][yi][4 * xi + 3] = data[swz.a];\n+ }\n+ }\n+ fptr += 4;\n+ nptr++;\n+ }\n+ }\n+ }\n+ }\n}\n/*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -186,9 +186,8 @@ void compute_error_metrics(\ndata8[ze1][ye1][xe1 + 2] * (1.0f / 255.0f),\ndata8[ze1][ye1][xe1 + 3] * (1.0f / 255.0f));\n}\n- else // if (img1->data_type == ASTCENC_TYPE_F16)\n+ else if (img1->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img1->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img1->data);\ncolor1 = float4(\nastc::clamp64Kf(sf16_to_float(data16[ze1][ye1][xe1 ])),\n@@ -196,6 +195,16 @@ void compute_error_metrics(\nastc::clamp64Kf(sf16_to_float(data16[ze1][ye1][xe1 + 2])),\nastc::clamp64Kf(sf16_to_float(data16[ze1][ye1][xe1 + 3])));\n}\n+ else // if (img1->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img1->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img1->data);\n+ color1 = float4(\n+ astc::clamp64Kf(data32[ze1][ye1][xe1 ]),\n+ astc::clamp64Kf(data32[ze1][ye1][xe1 + 1]),\n+ astc::clamp64Kf(data32[ze1][ye1][xe1 + 2]),\n+ astc::clamp64Kf(data32[ze1][ye1][xe1 + 3]));\n+ }\nif (img2->data_type == ASTCENC_TYPE_U8)\n{\n@@ -206,9 +215,8 @@ void compute_error_metrics(\ndata8[ze2][ye2][xe2 + 2] * (1.0f / 255.0f),\ndata8[ze2][ye2][xe2 + 3] * (1.0f / 255.0f));\n}\n- else // if (img2->data_type == ASTCENC_TYPE_F16)\n+ else if (img2->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img2->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img2->data);\ncolor2 = float4(\nastc::clamp64Kf(sf16_to_float(data16[ze2][ye2][xe2])),\n@@ -216,6 +224,16 @@ void compute_error_metrics(\nastc::clamp64Kf(sf16_to_float(data16[ze2][ye2][xe2 + 2])),\nastc::clamp64Kf(sf16_to_float(data16[ze2][ye2][xe2 + 3])));\n}\n+ else // if (img2->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img2->data_type == ASTCENC_TYPE_F32);\n+ float*** data16 = static_cast<float***>(img2->data);\n+ color2 = float4(\n+ astc::clamp64Kf(data16[ze2][ye2][xe2]),\n+ astc::clamp64Kf(data16[ze2][ye2][xe2 + 1]),\n+ astc::clamp64Kf(data16[ze2][ye2][xe2 + 2]),\n+ astc::clamp64Kf(data16[ze2][ye2][xe2 + 3]));\n+ }\nrgb_peak = MAX(MAX(color1.x, color1.y), MAX(color1.z, rgb_peak));\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image.cpp", "new_path": "Source/astcenccli_image.cpp", "diff": "@@ -41,7 +41,6 @@ astcenc_image *alloc_image(\nunsigned int dim_ey = dim_y + 2 * dim_pad;\nunsigned int dim_ez = (dim_z == 1) ? 1 : dim_z + 2 * dim_pad;\n- assert(bitness == 8 || bitness == 16);\nif (bitness == 8)\n{\nuint8_t*** data8 = new uint8_t **[dim_ez];\n@@ -90,6 +89,31 @@ astcenc_image *alloc_image(\nimg->data_type = ASTCENC_TYPE_F16;\nimg->data = static_cast<void*>(data16);\n}\n+ else // if (bitness == 32)\n+ {\n+ assert(bitness == 32);\n+ float*** data32 = new float**[dim_ez];\n+ data32[0] = new float*[dim_ez * dim_ey];\n+ data32[0][0] = new float[4 * dim_ez * dim_ey * dim_ex];\n+ memset(data32[0][0], 0, 8 * dim_ez * dim_ey * dim_ex);\n+\n+ for (unsigned int z = 1; z < dim_ez; z++)\n+ {\n+ data32[z] = data32[0] + z * dim_ey;\n+ data32[z][0] = data32[0][0] + 4 * z * dim_ex * dim_ey;\n+ }\n+\n+ for (unsigned int z = 0; z < dim_ez; z++)\n+ {\n+ for (unsigned int y = 1; y < dim_ey; y++)\n+ {\n+ data32[z][y] = data32[z][0] + 4 * y * dim_ex;\n+ }\n+ }\n+\n+ img->data_type = ASTCENC_TYPE_F32;\n+ img->data = static_cast<void*>(data32);\n+ }\nreturn img;\n}\n@@ -108,14 +132,21 @@ void free_image(astcenc_image * img)\ndelete[] data8[0];\ndelete[] data8;\n}\n- else // if (img->data_type == ASTCENC_TYPE_F16)\n+ else if (img->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img->data);\ndelete[] data16[0][0];\ndelete[] data16[0];\ndelete[] data16;\n}\n+ else // if (img->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img->data);\n+ delete[] data32[0][0];\n+ delete[] data32[0];\n+ delete[] data32;\n+ }\ndelete img;\n}\n@@ -166,9 +197,8 @@ void fill_image_padding_area(astcenc_image * img)\n}\n}\n}\n- else // if (img->data_type == ASTCENC_TYPE_F16)\n+ else if (img->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img->data);\nfor (unsigned int z = 0; z < dim_ez; z++)\n{\n@@ -187,6 +217,27 @@ void fill_image_padding_area(astcenc_image * img)\n}\n}\n}\n+ else // if (img->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img->data);\n+ for (unsigned int z = 0; z < dim_ez; z++)\n+ {\n+ int zc = MIN(MAX(z, zmin), zmax);\n+ for (unsigned int y = 0; y < dim_ey; y++)\n+ {\n+ int yc = MIN(MAX(y, ymin), ymax);\n+ for (unsigned int x = 0; x < dim_ex; x++)\n+ {\n+ int xc = MIN(MAX(x, xmin), xmax);\n+ for (unsigned int i = 0; i < 4; i++)\n+ {\n+ data32[z][y][4 * x + i] = data32[zc][yc][4 * xc + i];\n+ }\n+ }\n+ }\n+ }\n+ }\n}\nint determine_image_channels(const astcenc_image * img)\n@@ -198,16 +249,12 @@ int determine_image_channels(const astcenc_image * img)\n// scan through the image data\n// to determine how many color channels the image has.\n- int lum_mask;\n- int alpha_mask;\n- int alpha_mask_ref;\n+ bool is_luma = true;\n+ bool has_alpha = false;\nif (img->data_type == ASTCENC_TYPE_U8)\n{\nuint8_t*** data8 = static_cast<uint8_t***>(img->data);\n- alpha_mask_ref = 0xFF;\n- alpha_mask = 0xFF;\n- lum_mask = 0;\nfor (unsigned int z = 0; z < dim_z; z++)\n{\n@@ -219,21 +266,16 @@ int determine_image_channels(const astcenc_image * img)\nint g = data8[z][y][4 * x + 1];\nint b = data8[z][y][4 * x + 2];\nint a = data8[z][y][4 * x + 3];\n- lum_mask |= (r ^ g) | (r ^ b);\n- alpha_mask &= a;\n+\n+ is_luma = is_luma && (r == g) && (r == b);\n+ has_alpha = has_alpha || (a != 0xFF);\n}\n}\n}\n}\n- else // if (img->data_type == ASTCENC_TYPE_F16)\n+ else if (img->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img->data_type == ASTCENC_TYPE_F16);\n-\nuint16_t*** data16 = static_cast<uint16_t***>(img->data);\n- alpha_mask_ref = 0xFFFF;\n- alpha_mask = 0xFFFF;\n- lum_mask = 0;\n-\nfor (unsigned int z = 0; z < dim_z; z++)\n{\nfor (unsigned int y = 0; y < dim_y; y++)\n@@ -244,14 +286,37 @@ int determine_image_channels(const astcenc_image * img)\nint g = data16[z][y][4 * x + 1];\nint b = data16[z][y][4 * x + 2];\nint a = data16[z][y][4 * x + 3];\n- lum_mask |= (r ^ g) | (r ^ b);\n- alpha_mask &= (a ^ 0xC3FF); // a ^ 0xC3FF returns FFFF if and only if the input is 1.0\n+\n+ is_luma = is_luma && (r == g) && (r == b);\n+ has_alpha = has_alpha || ((a ^ 0xC3FF) != 0xFFFF);\n+ // a ^ 0xC3FF returns FFFF if and only if the input is 1.0\n+ }\n+ }\n+ }\n+ }\n+ else // if (img->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img->data);\n+ for (unsigned int z = 0; z < dim_z; z++)\n+ {\n+ for (unsigned int y = 0; y < dim_y; y++)\n+ {\n+ for (unsigned int x = 0; x < dim_x; x++)\n+ {\n+ float r = data32[z][y][4 * x];\n+ float g = data32[z][y][4 * x + 1];\n+ float b = data32[z][y][4 * x + 2];\n+ float a = data32[z][y][4 * x + 3];\n+\n+ is_luma = is_luma && (r == g) && (r == b);\n+ has_alpha = has_alpha || (a != 1.0f);\n}\n}\n}\n}\n- int image_channels = 1 + (lum_mask == 0 ? 0 : 2) + (alpha_mask == alpha_mask_ref ? 0 : 1);\n+ int image_channels = 1 + (is_luma == 0 ? 0 : 2) + (has_alpha ? 0 : 1);\nreturn image_channels;\n}\n@@ -263,11 +328,12 @@ astcenc_image* astc_img_from_floatx4_array(\nunsigned int dim_pad,\nbool y_flip\n) {\n+ // TODO: Make this 32 to use direct passthough as float\nastcenc_image* img = alloc_image(16, dim_x, dim_y, 1, dim_pad);\nfor (unsigned int y = 0; y < dim_y; y++)\n{\n- uint16_t*** data16 = static_cast<uint16_t***>(img->data);\n+ float*** data32 = static_cast<float***>(img->data);\nunsigned int y_dst = y + dim_pad;\nunsigned int y_src = y_flip ? (dim_y - y - 1) : y;\nconst float* src = data + 4 * dim_y * y_src;\n@@ -275,10 +341,10 @@ astcenc_image* astc_img_from_floatx4_array(\nfor (unsigned int x = 0; x < dim_x; x++)\n{\nunsigned int x_dst = x + dim_pad;\n- data16[0][y_dst][4 * x_dst] = float_to_sf16(src[4 * x], SF_NEARESTEVEN);\n- data16[0][y_dst][4 * x_dst + 1] = float_to_sf16(src[4 * x + 1], SF_NEARESTEVEN);\n- data16[0][y_dst][4 * x_dst + 2] = float_to_sf16(src[4 * x + 2], SF_NEARESTEVEN);\n- data16[0][y_dst][4 * x_dst + 3] = float_to_sf16(src[4 * x + 3], SF_NEARESTEVEN);\n+ data32[0][y_dst][4 * x_dst ] = src[4 * x ];\n+ data32[0][y_dst][4 * x_dst + 1] = src[4 * x + 1];\n+ data32[0][y_dst][4 * x_dst + 2] = src[4 * x + 2];\n+ data32[0][y_dst][4 * x_dst + 3] = src[4 * x + 3];\n}\n}\n@@ -346,9 +412,8 @@ float* floatx4_array_from_astc_img(\n}\n}\n}\n- else // if (img->data_type == ASTCENC_TYPE_F16)\n+ else if (img->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img->data);\nfor (unsigned int y = 0; y < dim_y; y++)\n{\n@@ -365,6 +430,25 @@ float* floatx4_array_from_astc_img(\n}\n}\n}\n+ else // if (img->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img->data);\n+ for (unsigned int y = 0; y < dim_y; y++)\n+ {\n+ unsigned int ymod = y_flip ? dim_y - y - 1 : y;\n+ const float *src = data32[0][ymod + dim_pad] + (4 * dim_pad);\n+ float *dst = buf + y * dim_x * 4;\n+\n+ for (unsigned int x = 0; x < dim_x; x++)\n+ {\n+ dst[4 * x ] = src[4 * x ];\n+ dst[4 * x + 1] = src[4 * x + 1];\n+ dst[4 * x + 2] = src[4 * x + 2];\n+ dst[4 * x + 3] = src[4 * x + 3];\n+ }\n+ }\n+ }\nreturn buf;\n}\n@@ -398,9 +482,8 @@ uint8_t* unorm8x4_array_from_astc_img(\n}\n}\n}\n- else // if (img->data_type == ASTCENC_TYPE_F16)\n+ else if (img->data_type == ASTCENC_TYPE_F16)\n{\n- assert(img->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(img->data);\nfor (unsigned int y = 0; y < dim_y; y++)\n{\n@@ -417,6 +500,25 @@ uint8_t* unorm8x4_array_from_astc_img(\n}\n}\n}\n+ else // if (img->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(img->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(img->data);\n+ for (unsigned int y = 0; y < dim_y; y++)\n+ {\n+ unsigned int ymod = y_flip ? dim_y - y - 1 : y;\n+ const float* src = data32[0][ymod + dim_pad] + (4 * dim_pad);\n+ uint8_t* dst = buf + y * dim_x * 4;\n+\n+ for (unsigned int x = 0; x < dim_x; x++)\n+ {\n+ dst[4 * x] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(src[4*x ]) * 255.0f);\n+ dst[4 * x + 1] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(src[4*x+1]) * 255.0f);\n+ dst[4 * x + 2] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(src[4*x+2]) * 255.0f);\n+ dst[4 * x + 3] = (uint8_t)astc::flt2int_rtn(astc::clamp1f(src[4*x+3]) * 255.0f);\n+ }\n+ }\n+ }\nreturn buf;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -247,6 +247,7 @@ static astcenc_image* load_uncomp_file(\n{\nunsigned int dim_x = slices[0]->dim_x;\nunsigned int dim_y = slices[0]->dim_y;\n+ // TODO: Make this 32 to use direct pass though as float\nint bitness = is_hdr ? 16 : 8;\nint slice_size = (dim_x + (2 * dim_pad)) * (dim_y + (2 * dim_pad));\n@@ -262,14 +263,21 @@ static astcenc_image* load_uncomp_file(\nsize_t copy_size = slice_size * 4 * sizeof(uint8_t);\nmemcpy(*data8[z], *data8src[0], copy_size);\n}\n- else // if (image->data_type == ASTCENC_TYPE_F16)\n+ else if (image->data_type == ASTCENC_TYPE_F16)\n{\n- assert(image->data_type == ASTCENC_TYPE_F16);\nuint16_t*** data16 = static_cast<uint16_t***>(image->data);\nuint16_t*** data16src = static_cast<uint16_t***>(slices[z - dim_pad]->data);\nsize_t copy_size = slice_size * 4 * sizeof(uint16_t);\nmemcpy(*data16[z], *data16src[0], copy_size);\n}\n+ else // if (image->data_type == ASTCENC_TYPE_F32)\n+ {\n+ assert(image->data_type == ASTCENC_TYPE_F32);\n+ float*** data32 = static_cast<float***>(image->data);\n+ float*** data32src = static_cast<float***>(slices[z - dim_pad]->data);\n+ size_t copy_size = slice_size * 4 * sizeof(float);\n+ memcpy(*data32[z], *data32src[0], copy_size);\n+ }\n}\n// Fill in the padding slices with clamped data\n@@ -1123,6 +1131,7 @@ int main(\nif (out_bitness == -1)\n{\nbool is_hdr = (config.profile == ASTCENC_PRF_HDR) || (config.profile == ASTCENC_PRF_HDR_RGB_LDR_A);\n+ // TODO: Make this 32 to use direct passthrough as float\nout_bitness = is_hdr ? 16 : 8;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Implement support for F32 as core API channel type Code to use this for HDR images is also implemented for the CLI wrapper, but currently the HDR functionality in the wrapper is still routed though FP16. Local testing indicates that this works as expected.
61,745
16.10.2020 23:26:32
-3,600
43020621728ece5f3eec4c2cb2218d72144c546a
Update 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": "@@ -88,7 +88,6 @@ extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n// Select a block size to test\nint i = stream.ConsumeIntegralInRange<int>(0, testSz.size() - 1);\n- block_size_descriptor* bsd = &(testBSD[i]);\n// Populate the physical block\nphysical_compressed_block pcb;\n@@ -97,7 +96,7 @@ extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n// Call the function under test\nsymbolic_compressed_block scb;\n- physical_to_symbolic(bsd, pcb, &scb);\n+ physical_to_symbolic(testBSD[i], pcb, scb);\nreturn 0;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update fuzz test to new API
61,745
24.10.2020 23:03:23
-3,600
59cc114e374434ad7a6e24cd7f8fcaccdb5676a1
Bugfix for HDR file loading
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_image.cpp", "new_path": "Source/astcenccli_image.cpp", "diff": "@@ -333,6 +333,7 @@ astcenc_image* astc_img_from_floatx4_array(\nfor (unsigned int y = 0; y < dim_y; y++)\n{\n+#if 0\nfloat*** data32 = static_cast<float***>(img->data);\nunsigned int y_dst = y + dim_pad;\nunsigned int y_src = y_flip ? (dim_y - y - 1) : y;\n@@ -346,6 +347,21 @@ astcenc_image* astc_img_from_floatx4_array(\ndata32[0][y_dst][4 * x_dst + 2] = src[4 * x + 2];\ndata32[0][y_dst][4 * x_dst + 3] = src[4 * x + 3];\n}\n+#else\n+ uint16_t*** data16 = static_cast<uint16_t***>(img->data);\n+ unsigned int y_dst = y + dim_pad;\n+ unsigned int y_src = y_flip ? (dim_y - y - 1) : y;\n+ const float* src = data + 4 * dim_y * y_src;\n+\n+ for (unsigned int x = 0; x < dim_x; x++)\n+ {\n+ unsigned int x_dst = x + dim_pad;\n+ data16[0][y_dst][4 * x_dst] = float_to_sf16(src[4 * x], SF_NEARESTEVEN);\n+ data16[0][y_dst][4 * x_dst + 1] = float_to_sf16(src[4 * x + 1], SF_NEARESTEVEN);\n+ data16[0][y_dst][4 * x_dst + 2] = float_to_sf16(src[4 * x + 2], SF_NEARESTEVEN);\n+ data16[0][y_dst][4 * x_dst + 3] = float_to_sf16(src[4 * x + 3], SF_NEARESTEVEN);\n+ }\n+#endif\n}\nfill_image_padding_area(img);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_image_load_store.cpp", "new_path": "Source/astcenccli_image_load_store.cpp", "diff": "@@ -925,7 +925,7 @@ static astcenc_image* load_ktx_uncompressed_image(\n}\ncase GL_FLOAT:\n{\n- bitness = 16;\n+ bitness = 32;\nbytes_per_component = 4;\nswitch (hdr.gl_format)\n{\n@@ -1060,7 +1060,7 @@ static astcenc_image* load_ktx_uncompressed_image(\ndelete[] buf;\nfill_image_padding_area(astc_img);\n- is_hdr = bitness == 16;\n+ is_hdr = bitness == 32;\nnum_components = components;\nreturn astc_img;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Bugfix for HDR file loading
61,745
25.10.2020 19:56:52
0
e5d83ecdf1a4433810530af5140ad9eb7d4ca3ab
Fix SSE2 builds where min/max_epi32 is not available
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -85,6 +85,7 @@ HEADERS = \\\nastcenc.h \\\nastcenc_internal.h \\\nastcenc_mathlib.h \\\n+ astcenc_vecmathlib.h \\\nastcenccli_internal.h \\\nstb_image.h \\\nstb_image_write.h \\\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "// SPDX-License-Identifier: Apache-2.0\n// ----------------------------------------------------------------------------\n-// Copyright 2011-2020 Arm Limited\n+// Copyright 2019-2020 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@@ -118,6 +118,23 @@ SIMD_INLINE vint select(vint a, vint b, vint cond)\nreturn vint(_mm256_blendv_epi8(a.m, b.m, cond.m));\n}\n+SIMD_INLINE void print(vfloat a)\n+{\n+ alignas(ASTCENC_VECALIGN) float v[8];\n+ store(a, v);\n+ printf(\"v8_f32:\\n %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f\\n\",\n+ (double)v[0], (double)v[1], (double)v[2], (double)v[3],\n+ (double)v[4], (double)v[5], (double)v[6], (double)v[7]);\n+}\n+\n+SIMD_INLINE void print(vint a)\n+{\n+ alignas(ASTCENC_VECALIGN) int v[8];\n+ store(a, v);\n+ printf(\"v8_i32:\\n %8u %8u %8u %8u %8u %8u %8u %8u\\n\",\n+ v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);\n+}\n+\n#endif // #ifdef ASTCENC_SIMD_ISA_AVX2\n@@ -196,8 +213,26 @@ SIMD_INLINE vint operator<(vint a, vint b) { a.m = _mm_cmplt_epi32(a.m, b.m); re\nSIMD_INLINE vint operator>(vint a, vint b) { a.m = _mm_cmpgt_epi32(a.m, b.m); return a; }\nSIMD_INLINE vint operator==(vint a, vint b) { a.m = _mm_cmpeq_epi32(a.m, b.m); return a; }\nSIMD_INLINE vint operator!=(vint a, vint b) { a.m = _mm_cmpeq_epi32(a.m, b.m); return ~a; }\n-SIMD_INLINE vint min(vint a, vint b) { a.m = _mm_min_epi32(a.m, b.m); return a; }\n-SIMD_INLINE vint max(vint a, vint b) { a.m = _mm_max_epi32(a.m, b.m); return a; }\n+\n+SIMD_INLINE vint min(vint a, vint b) {\n+#if ASTCENC_SSE >= 41\n+ a.m = _mm_min_epi32(a.m, b.m);\n+#else\n+ vint d = a < b;\n+ a.m = _mm_or_si128(_mm_and_si128(d.m, a.m), _mm_andnot_si128(d.m, b.m));\n+#endif\n+ return a;\n+}\n+\n+SIMD_INLINE vint max(vint a, vint b) {\n+#if ASTCENC_SSE >= 41\n+ a.m = _mm_max_epi32(a.m, b.m);\n+#else\n+ vint d = a > b;\n+ a.m = _mm_or_si128(_mm_and_si128(d.m, a.m), _mm_andnot_si128(d.m, b.m));\n+#endif\n+ return a;\n+}\nSIMD_INLINE void store(vfloat v, float* ptr) { _mm_store_ps(ptr, v.m); }\nSIMD_INLINE void store(vint v, int* ptr) { _mm_store_si128((__m128i*)ptr, v.m); }\n@@ -217,6 +252,7 @@ SIMD_INLINE vfloat select(vfloat a, vfloat b, vfloat cond)\n#endif\nreturn a;\n}\n+\nSIMD_INLINE vint select(vint a, vint b, vint cond)\n{\n#if ASTCENC_SSE >= 41\n@@ -227,6 +263,23 @@ SIMD_INLINE vint select(vint a, vint b, vint cond)\n#endif\n}\n+SIMD_INLINE void print(vfloat a)\n+{\n+ alignas(ASTCENC_VECALIGN) float v[4];\n+ store(a, v);\n+ printf(\"v4_f32:\\n %0.4f %0.4f %0.4f %0.4f\\n\",\n+ (double)v[0], (double)v[1], (double)v[2], (double)v[3]);\n+}\n+\n+SIMD_INLINE void print(vint a)\n+{\n+ alignas(ASTCENC_VECALIGN) int v[4];\n+ store(a, v);\n+ printf(\"v4_i32:\\n %8u %8u %8u %8u\\n\",\n+ v[0], v[1], v[2], v[3]);\n+}\n+\n+\n#endif // #ifdef ASTCENC_SIMD_ISA_SSE\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix SSE2 builds where min/max_epi32 is not available
61,745
26.10.2020 21:21:25
0
5b31f3a7c53bbe63d8aef81412a78f4995cd47fb
Add test ref support for SSE2 and 4.2 builds
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -249,11 +249,35 @@ def get_encoder_params(encoderName, referenceName, imageSet):\nname = \"reference-1.7\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n+ elif encoderName == \"ref-2.0-sse2\":\n+ encoder = te.Encoder2_0(\"sse2\")\n+ name = \"reference-2.0-sse2\"\n+ outDir = \"Test/Images/%s\" % imageSet\n+ refName = None\n+ elif encoderName == \"ref-2.0-sse4.2\":\n+ encoder = te.Encoder2_0(\"sse4.2\")\n+ name = \"reference-2.0-sse4.2\"\n+ outDir = \"Test/Images/%s\" % imageSet\n+ refName = None\nelif encoderName == \"ref-2.0-avx2\":\nencoder = te.Encoder2_0(\"avx2\")\nname = \"reference-2.0-avx2\"\noutDir = \"Test/Images/%s\" % imageSet\nrefName = None\n+ elif encoderName == \"ref-master-sse2\":\n+ # Warning: this option rebuilds a new reference test result for the\n+ # master branch using the user's locally build encoder in ./Source.\n+ encoder = te.Encoder2x(\"sse2\")\n+ name = \"reference-master-sse2\"\n+ outDir = \"Test/Images/%s\" % imageSet\n+ refName = None\n+ elif encoderName == \"ref-master-sse4.2\":\n+ # Warning: this option rebuilds a new reference test result for the\n+ # master branch using the user's locally build encoder in ./Source.\n+ encoder = te.Encoder2x(\"sse4.2\")\n+ name = \"reference-master-sse4.2\"\n+ outDir = \"Test/Images/%s\" % imageSet\n+ refName = None\nelif encoderName == \"ref-master-avx2\":\n# Warning: this option rebuilds a new reference test result for the\n# master branch using the user's locally build encoder in ./Source.\n@@ -279,7 +303,9 @@ def parse_command_line():\n\"\"\"\nparser = argparse.ArgumentParser()\n- refcoders = [\"ref-1.7\", \"ref-2.0-avx2\", \"ref-master-avx2\"]\n+ refcoders = [\"ref-1.7\",\n+ \"ref-2.0-sse2\", \"ref-2.0-sse4.2\", \"ref-2.0-avx2\",\n+ \"ref-master-sse2\", \"ref-master-sse4.2\", \"ref-master-avx2\"]\ntestcoders = [\"sse2\", \"sse4.2\", \"avx2\"]\ncoders = refcoders + testcoders + [\"all\", \"all-ref\"]\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add test ref support for SSE2 and 4.2 builds
61,745
26.10.2020 23:16:14
0
6a26d11603a8ef2eee3b6de3fbea95a423765858
Add intrinsic path for SSE 4.2 dot product
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -454,7 +454,7 @@ public:\n}\n};\n-template <typename T> class vtype4\n+template <typename T> class alignas(16) vtype4\n{\npublic:\nT x, y, z, w;\n@@ -509,7 +509,16 @@ static inline uint4 operator*(uint32_t p, uint4 q) { return q * p; }\nstatic inline float dot(float2 p, float2 q) { return p.x * q.x + p.y * q.y; }\nstatic inline float dot(float3 p, float3 q) { return p.x * q.x + p.y * q.y + p.z * q.z; }\n-static inline float dot(float4 p, float4 q) { return p.x * q.x + p.y * q.y + p.z * q.z + p.w * q.w; }\n+static inline float dot(float4 p, float4 q) {\n+#if ASTCENC_SSE >= 42\n+ __m128 pv = _mm_load_ps((float*)&p);\n+ __m128 qv = _mm_load_ps((float*)&q);\n+ __m128 t = _mm_dp_ps(pv, qv, 0xFF);\n+ return _mm_cvtss_f32(t);\n+#else\n+ return p.x * q.x + p.y * q.y + p.z * q.z + p.w * q.w;\n+#endif\n+}\nstatic inline float2 normalize(float2 p) { return p * astc::rsqrt(dot(p, p)); }\nstatic inline float3 normalize(float3 p) { return p * astc::rsqrt(dot(p, p)); }\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add intrinsic path for SSE 4.2 dot product
61,748
27.10.2020 17:27:50
-7,200
5eb1d7bd1d0f87efe7cd3f478f0cd241688a6cad
Vectorize compute_angular_offsets and atan2 Vectorize compute_angular_offsets and atan2 using new maths library Update angular steps table so AVX2 and SSE now actually return identical results
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -130,6 +130,7 @@ SIMD_INLINE vfloat loada(const float* p) { return vfloat(_mm256_load_ps(p)); }\nSIMD_INLINE vfloat operator+ (vfloat a, vfloat b) { a.m = _mm256_add_ps(a.m, b.m); return a; }\nSIMD_INLINE vfloat operator- (vfloat a, vfloat b) { a.m = _mm256_sub_ps(a.m, b.m); return a; }\nSIMD_INLINE vfloat operator* (vfloat a, vfloat b) { a.m = _mm256_mul_ps(a.m, b.m); return a; }\n+SIMD_INLINE vfloat operator/ (vfloat a, vfloat b) { a.m = _mm256_div_ps(a.m, b.m); return a; }\n// Per-lane float comparison operations\nSIMD_INLINE vmask operator==(vfloat a, vfloat b) { return vmask(_mm256_cmp_ps(a.m, b.m, _CMP_EQ_OQ)); }\n@@ -163,6 +164,12 @@ SIMD_INLINE vfloat saturate(vfloat a)\nreturn vfloat(_mm256_min_ps(_mm256_max_ps(a.m, zero), one));\n}\n+SIMD_INLINE vfloat abs(vfloat x)\n+{\n+ __m256 msk = _mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff));\n+ return vfloat(_mm256_and_ps(x.m, msk));\n+}\n+\n// Round to nearest integer (nearest even for .5 cases)\nSIMD_INLINE vfloat round(vfloat v)\n{\n@@ -174,6 +181,8 @@ SIMD_INLINE vint floatToInt(vfloat v) { return vint(_mm256_cvttps_epi32(v.m)); }\n// Reinterpret-bitcast integer vector as a float vector (this is basically a no-op on the CPU)\nSIMD_INLINE vfloat intAsFloat(vint v) { return vfloat(_mm256_castsi256_ps(v.m)); }\n+// Reinterpret-bitcast float vector as an integer vector (this is basically a no-op on the CPU)\n+SIMD_INLINE vint floatAsInt(vfloat v) { return vint(_mm256_castps_si256(v.m)); }\nSIMD_INLINE vint operator~ (vint a) { return vint(_mm256_xor_si256(a.m, _mm256_set1_epi32(-1))); }\nSIMD_INLINE vmask operator~ (vmask a) { return vmask(_mm256_xor_si256(_mm256_castps_si256(a.m), _mm256_set1_epi32(-1))); }\n@@ -182,6 +191,11 @@ SIMD_INLINE vmask operator~ (vmask a) { return vmask(_mm256_xor_si256(_mm256_cas\nSIMD_INLINE vint operator+ (vint a, vint b) { a.m = _mm256_add_epi32(a.m, b.m); return a; }\nSIMD_INLINE vint operator- (vint a, vint b) { a.m = _mm256_sub_epi32(a.m, b.m); return a; }\n+// Per-lane logical bit operations\n+SIMD_INLINE vint operator| (vint a, vint b) { return vint(_mm256_or_si256(a.m, b.m)); }\n+SIMD_INLINE vint operator& (vint a, vint b) { return vint(_mm256_and_si256(a.m, b.m)); }\n+SIMD_INLINE vint operator^ (vint a, vint b) { return vint(_mm256_xor_si256(a.m, b.m)); }\n+\n// Per-lane integer comparison operations\nSIMD_INLINE vmask operator< (vint a, vint b) { return vmask(_mm256_cmpgt_epi32(b.m, a.m)); }\nSIMD_INLINE vmask operator> (vint a, vint b) { return vmask(_mm256_cmpgt_epi32(a.m, b.m)); }\n@@ -342,6 +356,7 @@ SIMD_INLINE vfloat loada(const float* p) { return vfloat(_mm_load_ps(p)); }\nSIMD_INLINE vfloat operator+ (vfloat a, vfloat b) { a.m = _mm_add_ps(a.m, b.m); return a; }\nSIMD_INLINE vfloat operator- (vfloat a, vfloat b) { a.m = _mm_sub_ps(a.m, b.m); return a; }\nSIMD_INLINE vfloat operator* (vfloat a, vfloat b) { a.m = _mm_mul_ps(a.m, b.m); return a; }\n+SIMD_INLINE vfloat operator/ (vfloat a, vfloat b) { a.m = _mm_div_ps(a.m, b.m); return a; }\nSIMD_INLINE vmask operator==(vfloat a, vfloat b) { return vmask(_mm_cmpeq_ps(a.m, b.m)); }\nSIMD_INLINE vmask operator!=(vfloat a, vfloat b) { return vmask(_mm_cmpneq_ps(a.m, b.m)); }\nSIMD_INLINE vmask operator< (vfloat a, vfloat b) { return vmask(_mm_cmplt_ps(a.m, b.m)); }\n@@ -365,6 +380,12 @@ SIMD_INLINE vfloat saturate(vfloat a)\nreturn vfloat(_mm_min_ps(_mm_max_ps(a.m, zero), one));\n}\n+SIMD_INLINE vfloat abs(vfloat x)\n+{\n+ __m128 msk = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));\n+ return vfloat(_mm_and_ps(x.m, msk));\n+}\n+\nSIMD_INLINE vfloat round(vfloat v)\n{\n#if ASTCENC_SSE >= 41\n@@ -389,12 +410,16 @@ SIMD_INLINE vfloat round(vfloat v)\nSIMD_INLINE vint floatToInt(vfloat v) { return vint(_mm_cvttps_epi32(v.m)); }\nSIMD_INLINE vfloat intAsFloat(vint v) { return vfloat(_mm_castsi128_ps(v.m)); }\n+SIMD_INLINE vint floatAsInt(vfloat v) { return vint(_mm_castps_si128(v.m)); }\nSIMD_INLINE vint operator~ (vint a) { return vint(_mm_xor_si128(a.m, _mm_set1_epi32(-1))); }\nSIMD_INLINE vmask operator~ (vmask a) { return vmask(_mm_xor_si128(_mm_castps_si128(a.m), _mm_set1_epi32(-1))); }\nSIMD_INLINE vint operator+ (vint a, vint b) { a.m = _mm_add_epi32(a.m, b.m); return a; }\nSIMD_INLINE vint operator- (vint a, vint b) { a.m = _mm_sub_epi32(a.m, b.m); return a; }\n+SIMD_INLINE vint operator| (vint a, vint b) { return vint(_mm_or_si128(a.m, b.m)); }\n+SIMD_INLINE vint operator& (vint a, vint b) { return vint(_mm_and_si128(a.m, b.m)); }\n+SIMD_INLINE vint operator^ (vint a, vint b) { return vint(_mm_xor_si128(a.m, b.m)); }\nSIMD_INLINE vmask operator< (vint a, vint b) { return vmask(_mm_cmplt_epi32(a.m, b.m)); }\nSIMD_INLINE vmask operator> (vint a, vint b) { return vmask(_mm_cmpgt_epi32(a.m, b.m)); }\nSIMD_INLINE vmask operator==(vint a, vint b) { return vmask(_mm_cmpeq_epi32(a.m, b.m)); }\n@@ -517,6 +542,10 @@ SIMD_INLINE void print(vint a)\n#ifdef ASTCENC_SIMD_ISA_SCALAR\n+#include <algorithm>\n+#include <math.h>\n+#include <string.h>\n+\n#define ASTCENC_SIMD_WIDTH 1\nstruct vfloat\n@@ -553,6 +582,7 @@ SIMD_INLINE vfloat loada(const float* p) { return vfloat(*p); }\nSIMD_INLINE vfloat operator+ (vfloat a, vfloat b) { a.m = a.m + b.m; return a; }\nSIMD_INLINE vfloat operator- (vfloat a, vfloat b) { a.m = a.m - b.m; return a; }\nSIMD_INLINE vfloat operator* (vfloat a, vfloat b) { a.m = a.m * b.m; return a; }\n+SIMD_INLINE vfloat operator/ (vfloat a, vfloat b) { a.m = a.m / b.m; return a; }\nSIMD_INLINE vmask operator==(vfloat a, vfloat b) { return vmask(a.m = a.m == b.m); }\nSIMD_INLINE vmask operator!=(vfloat a, vfloat b) { return vmask(a.m = a.m != b.m); }\nSIMD_INLINE vmask operator< (vfloat a, vfloat b) { return vmask(a.m = a.m < b.m); }\n@@ -570,6 +600,8 @@ SIMD_INLINE vfloat min(vfloat a, vfloat b) { a.m = a.m < b.m ? a.m : b.m; return\nSIMD_INLINE vfloat max(vfloat a, vfloat b) { a.m = a.m > b.m ? a.m : b.m; return a; }\nSIMD_INLINE vfloat saturate(vfloat a) { return vfloat(std::min(std::max(a.m,0.0f), 1.0f)); }\n+SIMD_INLINE vfloat abs(vfloat x) { return vfloat(std::abs(x.m)); }\n+\nSIMD_INLINE vfloat round(vfloat v)\n{\nreturn vfloat(std::floor(v.m + 0.5f));\n@@ -578,10 +610,14 @@ SIMD_INLINE vfloat round(vfloat v)\nSIMD_INLINE vint floatToInt(vfloat v) { return vint(v.m); }\nSIMD_INLINE vfloat intAsFloat(vint v) { vfloat r; memcpy(&r.m, &v.m, 4); return r; }\n+SIMD_INLINE vint floatAsInt(vfloat v) { vint r; memcpy(&r.m, &v.m, 4); return r; }\nSIMD_INLINE vint operator~ (vint a) { a.m = ~a.m; return a; }\nSIMD_INLINE vint operator+ (vint a, vint b) { a.m = a.m + b.m; return a; }\nSIMD_INLINE vint operator- (vint a, vint b) { a.m = a.m - b.m; return a; }\n+SIMD_INLINE vint operator| (vint a, vint b) { return vint(a.m | b.m); }\n+SIMD_INLINE vint operator& (vint a, vint b) { return vint(a.m & b.m); }\n+SIMD_INLINE vint operator^ (vint a, vint b) { return vint(a.m ^ b.m); }\nSIMD_INLINE vmask operator< (vint a, vint b) { return vmask(a.m = a.m < b.m); }\nSIMD_INLINE vmask operator> (vint a, vint b) { return vmask(a.m = a.m > b.m); }\nSIMD_INLINE vmask operator==(vint a, vint b) { return vmask(a.m = a.m == b.m); }\n@@ -626,4 +662,52 @@ SIMD_INLINE vint select(vint a, vint b, vmask cond)\n#endif // #ifdef ASTCENC_SIMD_ISA_SCALAR\n+\n+// ----------------------------------------------------------------------------\n+\n+// Return x, with each lane having its sign flipped where the corresponding y lane is negative, i.e. msb(y) ? -x : x\n+SIMD_INLINE vfloat changesign(vfloat x, vfloat y)\n+{\n+ vint ix = floatAsInt(x);\n+ vint iy = floatAsInt(y);\n+ vint signMask((int)0x80000000);\n+ vint r = ix ^ (iy & signMask);\n+ return intAsFloat(r);\n+}\n+\n+#define ASTCENC_PI_OVER_TWO (1.57079632679489661923f) // pi/2\n+#define ASTCENC_PI (3.14159265358979323846f)\n+\n+SIMD_INLINE vfloat atan(vfloat x)\n+{\n+ vmask c = abs(x) > vfloat(1.0f);\n+ vfloat z = changesign(vfloat(ASTCENC_PI_OVER_TWO), x);\n+ vfloat y = select(x, vfloat(1.0f) / x, c);\n+\n+ // max error 0.000167\n+ /*\n+ vfloat c1(0.999802172f);\n+ vfloat c3(-0.325227708f);\n+ vfloat c5(0.153163940f);\n+ vfloat c7(-0.042340223f);\n+ vfloat y2 = y * y;\n+ vfloat y4 = y2 * y2;\n+ vfloat y6 = y4 * y2;\n+ y = y * (c7 * y6 + (c5 * y4 + (c3 * y2 + c1)));\n+ */\n+ // max error 0.004883, matches astc::atan2 approximation\n+ vfloat y2 = y * y;\n+ y = y / (y2 * vfloat(0.28f) + vfloat(1.0f));\n+\n+ return select(y, z - y, c);\n+}\n+\n+SIMD_INLINE vfloat atan2(vfloat y, vfloat x)\n+{\n+ vfloat z = atan(abs(y / x));\n+ vmask xmask = vmask(floatAsInt(x).m);\n+ return changesign(select(z, vfloat(ASTCENC_PI) - z, xmask), y);\n+}\n+\n+\n#endif // #ifndef ASTC_VECMATHLIB_H_INCLUDED\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "#else\n#error Unknown SIMD width\n#endif\n+static_assert((ANGULAR_STEPS % ASTCENC_SIMD_WIDTH) == 0, \"ANGULAR_STEPS should be multiple of ASTCENC_SIMD_WIDTH\");\nalignas(ASTCENC_VECALIGN) static const float angular_steppings[ANGULAR_STEPS] = {\n1.0f, 1.25f, 1.5f, 1.75f,\n@@ -78,9 +79,9 @@ alignas(ASTCENC_VECALIGN) static const float angular_steppings[ANGULAR_STEPS] =\n// This is \"redundant\" and only used in more-than-4-wide\n// SIMD code paths, to make the steps table size\n// be a multiple of SIMD width. Values are replicated\n- // from previous row so that AVX2 and SSE code paths\n+ // from last entry so that AVX2 and SSE code paths\n// return the same results.\n- 32.0f, 33.0f, 34.0f, 35.0f,\n+ 35.0f, 35.0f, 35.0f, 35.0f,\n#endif\n};\n@@ -93,8 +94,8 @@ static int max_angular_steps_needed_for_quant_level[13];\n// slight quality loss compared to using sin() and cos() directly. Must be 2^N.\n#define SINCOS_STEPS 64\n-static float sin_table[SINCOS_STEPS][ANGULAR_STEPS];\n-static float cos_table[SINCOS_STEPS][ANGULAR_STEPS];\n+alignas(ASTCENC_VECALIGN) static float sin_table[SINCOS_STEPS][ANGULAR_STEPS];\n+alignas(ASTCENC_VECALIGN) static float cos_table[SINCOS_STEPS][ANGULAR_STEPS];\nvoid prepare_angular_tables()\n{\n@@ -135,14 +136,10 @@ static void compute_angular_offsets(\nint max_angular_steps,\nfloat* offsets\n) {\n- float anglesum_x[ANGULAR_STEPS];\n- float anglesum_y[ANGULAR_STEPS];\n-\n- for (int i = 0; i < max_angular_steps; i++)\n- {\n- anglesum_x[i] = 0;\n- anglesum_y[i] = 0;\n- }\n+ alignas(ASTCENC_VECALIGN) float anglesum_x[ANGULAR_STEPS];\n+ alignas(ASTCENC_VECALIGN) float anglesum_y[ANGULAR_STEPS];\n+ memset(anglesum_x, 0, max_angular_steps*sizeof(anglesum_x[0]));\n+ memset(anglesum_y, 0, max_angular_steps*sizeof(anglesum_y[0]));\n// compute the angle-sums.\nfor (int i = 0; i < samplecount; i++)\n@@ -156,21 +153,25 @@ static void compute_angular_offsets(\nconst float *sinptr = sin_table[isample];\nconst float *cosptr = cos_table[isample];\n- for (int j = 0; j < max_angular_steps; j++)\n+ vfloat sample_weightv(sample_weight);\n+ for (int j = 0; j < max_angular_steps; j += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n{\n- float cp = cosptr[j];\n- float sp = sinptr[j];\n-\n- anglesum_x[j] += cp * sample_weight;\n- anglesum_y[j] += sp * sample_weight;\n+ vfloat cp = loada(&cosptr[j]);\n+ vfloat sp = loada(&sinptr[j]);\n+ vfloat ax = loada(&anglesum_x[j]) + cp * sample_weightv;\n+ vfloat ay = loada(&anglesum_y[j]) + sp * sample_weightv;\n+ store(ax, &anglesum_x[j]);\n+ store(ay, &anglesum_y[j]);\n}\n}\n// post-process the angle-sums\n- for (int i = 0; i < max_angular_steps; i++)\n+ vfloat mult = vfloat(1.0f / (2.0f * (float)M_PI));\n+ for (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n{\n- float angle = astc::atan2(anglesum_y[i], anglesum_x[i]);\n- offsets[i] = angle * (stepsizes[i] * (1.0f / (2.0f * (float)M_PI)));\n+ vfloat angle = atan2(loada(&anglesum_y[i]), loada(&anglesum_x[i]));\n+ vfloat ofs = angle * (loada(&stepsizes[i]) * mult);\n+ store(ofs, &offsets[i]);\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Vectorize compute_angular_offsets and atan2 (#168) Vectorize compute_angular_offsets and atan2 using new maths library Update angular steps table so AVX2 and SSE now actually return identical results
61,745
27.10.2020 19:19:35
0
cefe2406ac6b2997330b2eee86d8c3054a7e345c
Add missing header which trips some compilers
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "#include <stdio.h>\n#include <cassert>\n+#include <cstring>\n#if ASTCENC_SIMD_WIDTH <= 4\n#define ANGULAR_STEPS 44\n@@ -138,8 +139,8 @@ static void compute_angular_offsets(\n) {\nalignas(ASTCENC_VECALIGN) float anglesum_x[ANGULAR_STEPS];\nalignas(ASTCENC_VECALIGN) float anglesum_y[ANGULAR_STEPS];\n- memset(anglesum_x, 0, max_angular_steps*sizeof(anglesum_x[0]));\n- memset(anglesum_y, 0, max_angular_steps*sizeof(anglesum_y[0]));\n+ std::memset(anglesum_x, 0, max_angular_steps*sizeof(anglesum_x[0]));\n+ std::memset(anglesum_y, 0, max_angular_steps*sizeof(anglesum_y[0]));\n// compute the angle-sums.\nfor (int i = 0; i < samplecount; i++)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add missing header which trips some compilers
61,745
27.10.2020 21:53:32
0
7a57e172104946c1d8bc01a9ab69d990f6dcd7ad
Suppress nodebug attribute warnings on gcc builds
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "// ----------------------------------------------------------------------------\n/*\n- * This module implements N-wide float and integer vectors and common\n- * operations on them; with N depending on underlying ISA (e.g. 4 for SSE, 1 for\n- * pure scalar).\n+ * This module implements flexible N-wide float and integer vectors, where the\n+ * width can be selected at compile time depending on the underlying ISA. It\n+ * is not possible to mix different ISAs (or vector widths) in a single file -\n+ * the ISA is statically selected when the header is first included.\n+ *\n+ * ISA support is provided for:\n+ *\n+ * * 1-wide for scalar reference.\n+ * * 4-wide for SSE2.\n+ * * 4-wide for SSE4.2.\n+ * * 8-wide for AVX2.\n+ *\n*/\n#ifndef ASTC_VECMATHLIB_H_INCLUDED\n#if defined(_MSC_VER)\n#define SIMD_INLINE __forceinline\n+#elif defined(__GNUC__) && !defined(__clang__)\n+ #define SIMD_INLINE __attribute__((unused, always_inline)) inline\n#else\n#define SIMD_INLINE __attribute__((unused, always_inline, nodebug)) inline\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Suppress nodebug attribute warnings on gcc builds
61,745
27.10.2020 22:46:01
0
1a16847b3b541a8fb8951e2714fce70493abd1ab
Have a single definition of PI
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.cpp", "new_path": "Source/astcenc_mathlib.cpp", "diff": "@@ -64,21 +64,18 @@ float astc::atan2(\nfloat y,\nfloat x\n) {\n- const float PI = (float)M_PI;\n- const float PI_2 = PI / 2.0f;\n-\n// Handle the discontinuity at x == 0\nif (x == 0.0f)\n{\nif (y > 0.0f)\n{\n- return PI_2;\n+ return astc::PI_OVER_TWO;\n}\nelse if (y == 0.0f)\n{\nreturn 0.0f;\n}\n- return -PI_2;\n+ return -astc::PI_OVER_TWO;\n}\nfloat z = y / x;\n@@ -90,21 +87,21 @@ float astc::atan2(\n{\nif (y < 0.0f)\n{\n- return atan - PI;\n+ return atan - astc::PI;\n}\nelse\n{\n- return atan + PI;\n+ return atan + astc::PI;\n}\n}\nreturn atan;\n}\nelse\n{\n- float atan = PI_2 - (z / (z2 + 0.28f));\n+ float atan = astc::PI_OVER_TWO - (z / (z2 + 0.28f));\nif (y < 0.0f)\n{\n- return atan - PI;\n+ return atan - astc::PI;\n}\nelse\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "#include <immintrin.h>\n#endif\n-\n-#ifndef M_PI\n- #define M_PI 3.14159265358979323846\n-#endif\n-\n/* ============================================================================\nFast math library; note that many of the higher-order functions in this set\nuse approximations which are less accurate, but faster, than <cmath> standard\nnamespace astc\n{\n+static const float PI = 3.14159265358979323846f;\n+static const float PI_OVER_TWO = 1.57079632679489661923f;\n+\n/**\n* @brief Fast approximation of log2(x)\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -686,30 +686,13 @@ SIMD_INLINE vfloat changesign(vfloat x, vfloat y)\nreturn intAsFloat(r);\n}\n-#define ASTCENC_PI_OVER_TWO (1.57079632679489661923f) // pi/2\n-#define ASTCENC_PI (3.14159265358979323846f)\n-\n+// Fast atan implementation, with max error of 0.004883, matches astc::atan2\nSIMD_INLINE vfloat atan(vfloat x)\n{\nvmask c = abs(x) > vfloat(1.0f);\n- vfloat z = changesign(vfloat(ASTCENC_PI_OVER_TWO), x);\n+ vfloat z = changesign(vfloat(astc::PI_OVER_TWO), x);\nvfloat y = select(x, vfloat(1.0f) / x, c);\n-\n- // max error 0.000167\n- /*\n- vfloat c1(0.999802172f);\n- vfloat c3(-0.325227708f);\n- vfloat c5(0.153163940f);\n- vfloat c7(-0.042340223f);\n- vfloat y2 = y * y;\n- vfloat y4 = y2 * y2;\n- vfloat y6 = y4 * y2;\n- y = y * (c7 * y6 + (c5 * y4 + (c3 * y2 + c1)));\n- */\n- // max error 0.004883, matches astc::atan2 approximation\n- vfloat y2 = y * y;\n- y = y / (y2 * vfloat(0.28f) + vfloat(1.0f));\n-\n+ y = y / (y * y * vfloat(0.28f) + vfloat(1.0f));\nreturn select(y, z - y, c);\n}\n@@ -717,8 +700,7 @@ SIMD_INLINE vfloat atan2(vfloat y, vfloat x)\n{\nvfloat z = atan(abs(y / x));\nvmask xmask = vmask(floatAsInt(x).m);\n- return changesign(select(z, vfloat(ASTCENC_PI) - z, xmask), y);\n+ return changesign(select(z, vfloat(astc::PI) - z, xmask), y);\n}\n-\n#endif // #ifndef ASTC_VECMATHLIB_H_INCLUDED\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -108,8 +108,8 @@ void prepare_angular_tables()\nfor (int j = 0; j < SINCOS_STEPS; j++)\n{\n- sin_table[j][i] = static_cast<float>(sinf((2.0f * (float)M_PI / (SINCOS_STEPS - 1.0f)) * angular_steppings[i] * j));\n- cos_table[j][i] = static_cast<float>(cosf((2.0f * (float)M_PI / (SINCOS_STEPS - 1.0f)) * angular_steppings[i] * j));\n+ sin_table[j][i] = static_cast<float>(sinf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angular_steppings[i] * j));\n+ cos_table[j][i] = static_cast<float>(cosf((2.0f * astc::PI / (SINCOS_STEPS - 1.0f)) * angular_steppings[i] * j));\n}\nint p = astc::flt2int_rd(angular_steppings[i]) + 1;\n@@ -167,7 +167,7 @@ static void compute_angular_offsets(\n}\n// post-process the angle-sums\n- vfloat mult = vfloat(1.0f / (2.0f * (float)M_PI));\n+ vfloat mult = vfloat(1.0f / (2.0f * astc::PI));\nfor (int i = 0; i < max_angular_steps; i += ASTCENC_SIMD_WIDTH) // arrays are multiple of SIMD width (ANGULAR_STEPS), safe to overshoot max\n{\nvfloat angle = atan2(loada(&anglesum_y[i]), loada(&anglesum_x[i]));\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Have a single definition of PI
61,745
28.10.2020 12:01:08
0
3652bd0c4849a5cf0cd2c7f5b6decb4f3fcb1a92
Use alternative intrinsic encodings Use some intrinsics sequences which are compatible with older compilers (which miss some of the convenience encodings for the same underlying instruction). More ugly, but now works with GCC 7 and Clang 7.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -231,7 +231,13 @@ SIMD_INLINE vfloat hmin(vfloat v)\nshuf = _mm_movehl_ps(shuf, mins); // [ C D | D+C C+D ]\nmins = _mm_min_ss(mins, shuf);\n- vfloat vmin(_mm256_permute_ps(_mm256_set_m128(mins, mins), 0)); // _MM256_PERMUTE(0, 0, 0, 0, 0, 0, 0, 0)\n+\n+ // This is the most logical implementation, but the convenience intrinsic\n+ // is missing on older compilers (supported in g++ 9 and clang++ 9).\n+ //__m256i r = _mm256_set_m128(m, m)\n+ __m256 r = _mm256_insertf128_ps(_mm256_castps128_ps256(mins), mins, 1);\n+\n+ vfloat vmin(_mm256_permute_ps(r, 0));\nreturn vmin;\n}\n@@ -241,7 +247,12 @@ SIMD_INLINE vint hmin(vint v)\nm = _mm_min_epi32(m, _mm_shuffle_epi32(m, _MM_SHUFFLE(0,0,3,2)));\nm = _mm_min_epi32(m, _mm_shuffle_epi32(m, _MM_SHUFFLE(0,0,0,1)));\nm = _mm_shuffle_epi32(m, _MM_SHUFFLE(0,0,0,0));\n- vint vmin(_mm256_set_m128i(m, m));\n+\n+ // This is the most logical implementation, but the convenience intrinsic\n+ // is missing on older compilers (supported in g++ 9 and clang++ 9).\n+ //__m256i r = _mm256_set_m128i(m, m)\n+ __m256i r = _mm256_insertf128_si256(_mm256_castsi128_si256(m), m, 1);\n+ vint vmin(r);\nreturn vmin;\n}\n@@ -251,7 +262,13 @@ SIMD_INLINE void store(vfloat v, float* ptr) { _mm256_store_ps(ptr, v.m); }\nSIMD_INLINE void store(vint v, int* ptr) { _mm256_store_si256((__m256i*)ptr, v.m); }\n// Store lowest N (simd width) bytes of integer vector into an unaligned address.\n-SIMD_INLINE void store_nbytes(vint v, uint8_t* ptr) { _mm_storeu_si64(ptr, _mm256_extracti128_si256(v.m, 0)); }\n+SIMD_INLINE void store_nbytes(vint v, uint8_t* ptr)\n+{\n+ // This is the most logical implementation, but the convenience intrinsic\n+ // is missing on older compilers (supported in g++ 9 and clang++ 9).\n+ // _mm_storeu_si64(ptr, _mm256_extracti128_si256(v.m, 0))\n+ _mm_storel_epi64((__m128i*)ptr, _mm256_extracti128_si256(v.m, 0));\n+}\n// SIMD \"gather\" - load each lane with base[indices[i]]\nSIMD_INLINE vfloat gatherf(const float* base, vint indices)\n@@ -266,12 +283,20 @@ SIMD_INLINE vint gatheri(const int* base, vint indices)\n// Pack low 8 bits of each lane into low 64 bits of result.\nSIMD_INLINE vint pack_low_bytes(vint v)\n{\n- __m256i shuf = _mm256_set_epi8(0,0,0,0,0,0,0,0, 0,0,0,0,28,24,20,16, 0,0,0,0,0,0,0,0, 0,0,0,0,12,8,4,0);\n+ __m256i shuf = _mm256_set_epi8(0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 28, 24, 20, 16,\n+ 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 12, 8, 4, 0);\n__m256i a = _mm256_shuffle_epi8(v.m, shuf);\n__m128i a0 = _mm256_extracti128_si256(a, 0);\n__m128i a1 = _mm256_extracti128_si256(a, 1);\n__m128i b = _mm_unpacklo_epi32(a0, a1);\n- return vint(_mm256_set_m128i(b, b));\n+\n+ // This is the most logical implementation, but the convenience intrinsic\n+ // is missing on older compilers (supported in g++ 9 and clang++ 9).\n+ //__m256i r = _mm256_set_m128i(b, b)\n+ __m256i r = _mm256_insertf128_si256(_mm256_castsi128_si256(b), b, 1);\n+ return vint(r);\n}\n// \"select\", i.e. highbit(cond) ? b : a\n@@ -474,7 +499,13 @@ SIMD_INLINE vint hmin(vint v)\nSIMD_INLINE void store(vfloat v, float* ptr) { _mm_store_ps(ptr, v.m); }\nSIMD_INLINE void store(vint v, int* ptr) { _mm_store_si128((__m128i*)ptr, v.m); }\n-SIMD_INLINE void store_nbytes(vint v, uint8_t* ptr) { _mm_storeu_si32(ptr, v.m); }\n+SIMD_INLINE void store_nbytes(vint v, uint8_t* ptr)\n+{\n+ // This is the most logical implementation, but the convenience intrinsic\n+ // is missing on older compilers (supported in g++ 9 and clang++ 9).\n+ // _mm_storeu_si32(ptr, v.m);\n+ _mm_store_ss((float*)ptr, _mm_castsi128_ps(v.m));\n+}\nSIMD_INLINE vfloat gatherf(const float* base, vint indices)\n{\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use alternative intrinsic encodings Use some intrinsics sequences which are compatible with older compilers (which miss some of the convenience encodings for the same underlying instruction). More ugly, but now works with GCC 7 and Clang 7.
61,745
28.10.2020 18:54:02
0
f8b4c0627b4c3e9a904ae4adf9d4ace8c7f63395
Allow some more wiggle in PSNR outside of master box
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -34,16 +34,25 @@ Attributes:\nimport argparse\nimport os\n+import platform\nimport sys\nimport testlib.encoder as te\nimport testlib.testset as tts\nimport testlib.resultset as trs\n-\n+# Some behavior is CPU specific (precision of frcp is implementation-defined)\n+# so only require very tight thresholds on the reference test machine. Other\n+# machines must pass within 0.1dB of the reference scores.\n+if \"BSE2NGQ\" in platform.node():\nRESULT_THRESHOLD_WARN = -0.01\nRESULT_THRESHOLD_FAIL = -0.05\nRESULT_THRESHOLD_3D_FAIL = -0.02\n+else:\n+ RESULT_THRESHOLD_WARN = -0.05\n+ RESULT_THRESHOLD_FAIL = -0.1\n+ RESULT_THRESHOLD_3D_FAIL = -0.1\n+\nTEST_BLOCK_SIZES = [\"4x4\", \"5x5\", \"6x6\", \"8x8\", \"12x12\",\n\"3x3x3\", \"6x6x6\"]\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Allow some more wiggle in PSNR outside of master box
61,745
28.10.2020 22:02:07
0
d8012132d7ed27a500226185247c65c8a12cbd5d
Add float4 sqrt implementation
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -209,10 +209,7 @@ void compute_partition_error_color_weightings(\nfor (int i = 0; i < pcnt; i++)\n{\n- color_scalefactors[i].x = astc::sqrt(error_weightings[i].x);\n- color_scalefactors[i].y = astc::sqrt(error_weightings[i].y);\n- color_scalefactors[i].z = astc::sqrt(error_weightings[i].z);\n- color_scalefactors[i].w = astc::sqrt(error_weightings[i].w);\n+ color_scalefactors[i] = sqrt(error_weightings[i]);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "to future vectorization.\n============================================================================ */\n-// We support scalar versions of many maths functions which use SSE intrinsics\n-// as an \"optimized\" path, using just one lane from the SIMD hardware. In\n-// reality these are often slower than standard C due to setup and scheduling\n-// overheads, and the fact that we're not offsetting that cost with any actual\n-// vectorization.\n-//\n-// These variants are only included as a means to test that the accuracy of an\n-// SSE implementation would be acceptable before refactoring code paths to use\n-// an actual vectorized implementation which gets some advantage from SSE. It\n-// is therefore expected that the code will go *slower* with this macro\n-// set to 1 ...\n-#define USE_SCALAR_SSE 0\n-\n// These are namespaced to avoid colliding with C standard library functions.\nnamespace astc\n{\n@@ -98,15 +85,7 @@ float atan2(float y, float x);\n*/\nstatic inline float fabs(float val)\n{\n-#if (ASTCENC_SSE >= 20) && USE_SCALAR_SSE\n- static const union {\n- uint32_t u[4];\n- __m128 v;\n- } mask = { { 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff } };\n- return _mm_cvtss_f32(_mm_and_ps(_mm_set_ss(val), mask.v));\n-#else\nreturn std::fabs(val);\n-#endif\n}\n/**\n@@ -123,11 +102,7 @@ static inline float fabs(float val)\n*/\nstatic inline float fmin(float p, float q)\n{\n-#if (ASTCENC_SSE >= 20) && USE_SCALAR_SSE\n- return _mm_cvtss_f32(_mm_min_ss(_mm_set_ss(p),_mm_set_ss(q)));\n-#else\nreturn p < q ? p : q;\n-#endif\n}\n/**\n@@ -144,11 +119,7 @@ static inline float fmin(float p, float q)\n*/\nstatic inline float fmax(float p, float q)\n{\n-#if (ASTCENC_SSE >= 20) && USE_SCALAR_SSE\n- return _mm_cvtss_f32(_mm_max_ss(_mm_set_ss(p),_mm_set_ss(q)));\n-#else\nreturn q < p ? p : q;\n-#endif\n}\n/**\n@@ -240,14 +211,7 @@ static inline int clampi(int val, int low, int high)\n*/\nstatic inline float flt_rte(float val)\n{\n-#if (ASTCENC_SSE >= 42)\n- const int flag = _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC;\n- __m128 tmp = _mm_set_ss(val);\n- tmp = _mm_round_ss(tmp, tmp, flag);\n- return _mm_cvtss_f32(tmp);\n-#else\nreturn std::floor(val + 0.5f);\n-#endif\n}\n/**\n@@ -259,14 +223,7 @@ static inline float flt_rte(float val)\n*/\nstatic inline float flt_rd(float val)\n{\n-#if (ASTCENC_SSE >= 42)\n- const int flag = _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC;\n- __m128 tmp = _mm_set_ss(val);\n- tmp = _mm_round_ss(tmp, tmp, flag);\n- return _mm_cvtss_f32(tmp);\n-#else\nreturn std::floor(val);\n-#endif\n}\n/**\n@@ -278,11 +235,8 @@ static inline float flt_rd(float val)\n*/\nstatic inline int flt2int_rtn(float val)\n{\n-#if (ASTCENC_SSE >= 42) && USE_SCALAR_SSE\n- return _mm_cvt_ss2si(_mm_set_ss(val));\n-#else\n+\nreturn (int)(val + 0.5f);\n-#endif\n}\n/**\n@@ -294,11 +248,7 @@ static inline int flt2int_rtn(float val)\n*/\nstatic inline int flt2int_rd(float val)\n{\n-#if (ASTCENC_SSE >= 42) && USE_SCALAR_SSE\n- return _mm_cvt_ss2si(_mm_set_ss(val));\n-#else\nreturn (int)(val);\n-#endif\n}\n/**\n@@ -335,12 +285,7 @@ static inline int popcount(uint64_t p)\n*/\nstatic inline float rsqrt(float val)\n{\n-#if (ASTCENC_SSE >= 20) && USE_SCALAR_SSE\n- // FIXME: setting val = 99 causes a crash, which it really shouldn't.\n- return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(val)));\n-#else\nreturn 1.0f / std::sqrt(val);\n-#endif\n}\n/**\n@@ -352,27 +297,7 @@ static inline float rsqrt(float val)\n*/\nstatic inline float sqrt(float val)\n{\n-#if (ASTCENC_SSE >= 20) && USE_SCALAR_SSE\n- return 1.0f * astc::rsqrt(val);\n-#else\nreturn std::sqrt(val);\n-#endif\n-}\n-\n-/**\n- * @brief Fast approximation of 1.0 / val.\n- *\n- * @param val The input value.\n- *\n- * @return The approximated result.\n- */\n-static inline float recip(float val)\n-{\n-#if (ASTCENC_SSE >= 20) && USE_SCALAR_SSE\n- return _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ss(val)));\n-#else\n- return 1.0f / val;\n-#endif\n}\n/**\n@@ -522,6 +447,21 @@ static inline float2 normalize(float2 p) { return p * astc::rsqrt(dot(p, p)); }\nstatic inline float3 normalize(float3 p) { return p * astc::rsqrt(dot(p, p)); }\nstatic inline float4 normalize(float4 p) { return p * astc::rsqrt(dot(p, p)); }\n+static inline float4 sqrt(float4 p) {\n+ float4 r;\n+#if ASTCENC_SSE >= 20\n+ __m128 pv = _mm_load_ps((float*)&p);\n+ __m128 t = _mm_sqrt_ps(pv);\n+ _mm_store_ps((float*)&r, t);\n+#else\n+ r.x = std::sqrt(p.x);\n+ r.y = std::sqrt(p.y);\n+ r.z = std::sqrt(p.z);\n+ r.w = std::sqrt(p.w);\n+#endif\n+ return r;\n+}\n+\n#ifndef MIN\n#define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add float4 sqrt implementation
61,745
29.10.2020 08:12:20
0
97c1d83c735267a98788dc06bd97fa8c28892a1b
Remove old atan2 implementation
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.cpp", "new_path": "Source/astcenc_mathlib.cpp", "diff": "@@ -59,57 +59,6 @@ float astc::log2(float val)\nreturn res;\n}\n-/* Public function, see header file for detailed documentation */\n-float astc::atan2(\n- float y,\n- float x\n-) {\n- // Handle the discontinuity at x == 0\n- if (x == 0.0f)\n- {\n- if (y > 0.0f)\n- {\n- return astc::PI_OVER_TWO;\n- }\n- else if (y == 0.0f)\n- {\n- return 0.0f;\n- }\n- return -astc::PI_OVER_TWO;\n- }\n-\n- float z = y / x;\n- float z2 = z * z;\n- if (std::fabs(z) < 1.0f)\n- {\n- float atan = z / (1.0f + (0.28f * z2));\n- if (x < 0.0f)\n- {\n- if (y < 0.0f)\n- {\n- return atan - astc::PI;\n- }\n- else\n- {\n- return atan + astc::PI;\n- }\n- }\n- return atan;\n- }\n- else\n- {\n- float atan = astc::PI_OVER_TWO - (z / (z2 + 0.28f));\n- if (y < 0.0f)\n- {\n- return atan - astc::PI;\n- }\n- else\n- {\n- return atan;\n- }\n- }\n-}\n-\n/**\n* @brief 64-bit rotate left.\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -61,21 +61,6 @@ static const float PI_OVER_TWO = 1.57079632679489661923f;\n*/\nfloat log2(float val);\n-/**\n- * @brief Fast approximation of atan2.\n- *\n- * TODO: This implementation is reasonably accurate and a lot faster than the\n- * standard library, but quite branch heavy which makes it difficult to\n- * vectorize effectively. If we need to vectorize in future, consider using a\n- * different approximation algorithm.\n- *\n- * @param y The proportion of the Y coordinate.\n- * @param x The proportion of the X coordinate.\n- *\n- * @return The approximation of atan2().\n- */\n-float atan2(float y, float x);\n-\n/**\n* @brief SP float absolute value.\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib.h", "new_path": "Source/astcenc_vecmathlib.h", "diff": "@@ -717,7 +717,7 @@ SIMD_INLINE vfloat changesign(vfloat x, vfloat y)\nreturn intAsFloat(r);\n}\n-// Fast atan implementation, with max error of 0.004883, matches astc::atan2\n+// Fast atan implementation, with max error of 0.004883\nSIMD_INLINE vfloat atan(vfloat x)\n{\nvmask c = abs(x) > vfloat(1.0f);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove old atan2 implementation
61,748
29.10.2020 15:40:39
-7,200
46fabaa19e5d7b5c8d74aa7f7bf510fd5d6d8e43
Densely pack valid block weight modes Densely pack valid block weight modes, since only a small subset of the 2048 are valid.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_block_sizes2.cpp", "new_path": "Source/astcenc_block_sizes2.cpp", "diff": "@@ -659,12 +659,12 @@ static void construct_block_size_descriptor_2d(\n#endif\n// then construct the list of block formats\n- for (int i = 0; i < 2048; i++)\n+ int packed_idx = 0;\n+ for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n{\nint x_weights, y_weights;\nint is_dual_plane;\nint quantization_mode;\n- int fail = 0;\nint permit_encode = 1;\nif (decode_block_mode_2d(i, &x_weights, &y_weights, &is_dual_plane, &quantization_mode))\n@@ -676,39 +676,31 @@ static void construct_block_size_descriptor_2d(\n}\nelse\n{\n- fail = 1;\npermit_encode = 0;\n}\n- if (fail)\n- {\n- bsd->block_modes[i].decimation_mode = -1;\n- bsd->block_modes[i].quantization_mode = -1;\n- bsd->block_modes[i].is_dual_plane = -1;\n- bsd->block_modes[i].permit_encode = 0;\n- bsd->block_modes[i].permit_decode = 0;\n- bsd->block_modes[i].percentile = 1.0f;\n- }\n- else\n- {\n+ bsd->block_mode_to_packed[i] = -1;\n+ if (!permit_encode) // also disallow decode of grid size larger than block size.\n+ continue;\nint decimation_mode = decimation_mode_index[y_weights * 16 + x_weights];\n- bsd->block_modes[i].decimation_mode = decimation_mode;\n- bsd->block_modes[i].quantization_mode = quantization_mode;\n- bsd->block_modes[i].is_dual_plane = is_dual_plane;\n- bsd->block_modes[i].permit_encode = permit_encode;\n- bsd->block_modes[i].permit_decode = permit_encode; // disallow decode of grid size larger than block size.\n+ bsd->block_modes_packed[packed_idx].decimation_mode = decimation_mode;\n+ bsd->block_modes_packed[packed_idx].quantization_mode = quantization_mode;\n+ bsd->block_modes_packed[packed_idx].is_dual_plane = is_dual_plane;\n+ bsd->block_modes_packed[packed_idx].mode_index = i;\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\n- bsd->block_modes[i].percentile = percentiles[i];\n+ bsd->block_modes_packed[packed_idx].percentile = percentiles[i];\nif (bsd->decimation_mode_percentile[decimation_mode] > percentiles[i])\n{\nbsd->decimation_mode_percentile[decimation_mode] = percentiles[i];\n}\n#else\n- bsd->block_modes[i].percentile = 0.0f;\n+ bsd->block_modes_packed[packed_idx].percentile = 0.0f;\n#endif\n+ bsd->block_mode_to_packed[i] = packed_idx;\n+ ++packed_idx;\n}\n- }\n+ bsd->block_mode_packed_count = packed_idx;\n#if !defined(ASTCENC_DECOMPRESS_ONLY)\ndelete[] percentiles;\n@@ -849,12 +841,12 @@ static void construct_block_size_descriptor_3d(\nbsd->decimation_mode_count = decimation_mode_count;\n// then construct the list of block formats\n- for (int i = 0; i < 2048; i++)\n+ int packed_idx = 0;\n+ for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n{\nint x_weights, y_weights, z_weights;\nint is_dual_plane;\nint quantization_mode;\n- int fail = 0;\nint permit_encode = 1;\nif (decode_block_mode_3d(i, &x_weights, &y_weights, &z_weights, &is_dual_plane, &quantization_mode))\n@@ -866,34 +858,27 @@ static void construct_block_size_descriptor_3d(\n}\nelse\n{\n- fail = 1;\npermit_encode = 0;\n}\n- if (fail)\n- {\n- bsd->block_modes[i].decimation_mode = -1;\n- bsd->block_modes[i].quantization_mode = -1;\n- bsd->block_modes[i].is_dual_plane = -1;\n- bsd->block_modes[i].permit_encode = 0;\n- bsd->block_modes[i].permit_decode = 0;\n- bsd->block_modes[i].percentile = 1.0f;\n- }\n- else\n- {\n+ bsd->block_mode_to_packed[i] = -1;\n+ if (!permit_encode)\n+ continue;\n+\nint decimation_mode = decimation_mode_index[z_weights * 64 + y_weights * 8 + x_weights];\n- bsd->block_modes[i].decimation_mode = decimation_mode;\n- bsd->block_modes[i].quantization_mode = quantization_mode;\n- bsd->block_modes[i].is_dual_plane = is_dual_plane;\n- bsd->block_modes[i].permit_encode = permit_encode;\n- bsd->block_modes[i].permit_decode = permit_encode;\n+ bsd->block_modes_packed[packed_idx].decimation_mode = decimation_mode;\n+ bsd->block_modes_packed[packed_idx].quantization_mode = quantization_mode;\n+ bsd->block_modes_packed[packed_idx].is_dual_plane = is_dual_plane;\n+ bsd->block_modes_packed[packed_idx].mode_index = i;\n- bsd->block_modes[i].percentile = 0.0f; // No percentile table\n+ bsd->block_modes_packed[packed_idx].percentile = 0.0f; // No percentile table\nif (bsd->decimation_mode_percentile[decimation_mode] > 0.0f)\n{\nbsd->decimation_mode_percentile[decimation_mode] = 0.0f;\n}\n+ bsd->block_mode_to_packed[i] = packed_idx;\n+ ++packed_idx;\n}\n- }\n+ bsd->block_mode_packed_count = packed_idx;\nif (xdim * ydim * zdim <= 64)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_color_quantize.cpp", "new_path": "Source/astcenc_color_quantize.cpp", "diff": "*/\n#include <stdio.h>\n+#include <assert.h>\n#include \"astcenc_internal.h\"\n@@ -2069,6 +2070,7 @@ int pack_color_endpoints(\nint* output,\nint quantization_level\n) {\n+ assert(quantization_level >= 0 && quantization_level < 21);\n// we do not support negative colors.\ncolor0.x = MAX(color0.x, 0.0f);\ncolor0.y = MAX(color0.y, 0.0f);\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -57,15 +57,18 @@ static int realign_weights(\npt += scb->partition_index;\n// Get the quantization table\n- int weight_quantization_level = bsd->block_modes[scb->block_mode].quantization_mode;\n+ const int packed_index = bsd->block_mode_to_packed[scb->block_mode];\n+ assert(packed_index >= 0 && packed_index < bsd->block_mode_packed_count);\n+ const block_mode& bm = bsd->block_modes_packed[packed_index];\n+ int weight_quantization_level = bm.quantization_mode;\nconst quantization_and_transfer_table *qat = &(quant_and_xfer_tables[weight_quantization_level]);\n// Get the decimation table\nconst decimation_table *const *ixtab2 = bsd->decimation_tables;\n- const decimation_table *it = ixtab2[bsd->block_modes[scb->block_mode].decimation_mode];\n+ const decimation_table *it = ixtab2[bm.decimation_mode];\nint weight_count = it->num_weights;\n- int max_plane = bsd->block_modes[scb->block_mode].is_dual_plane;\n+ int max_plane = bm.is_dual_plane;\nint plane2_component = max_plane ? scb->plane2_color_component : 0;\nint plane_mask = max_plane ? 1 << plane2_component : 0;\n@@ -306,9 +309,10 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nint qwt_bitcounts[MAX_WEIGHT_MODES];\nfloat qwt_errors[MAX_WEIGHT_MODES];\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\n- if (bsd->block_modes[i].permit_encode == 0 || bsd->block_modes[i].is_dual_plane != 0 || bsd->block_modes[i].percentile > mode_cutoff)\n+ const block_mode& bm = bsd->block_modes_packed[i];\n+ if (bm.is_dual_plane != 0 || bm.percentile > mode_cutoff)\n{\nqwt_errors[i] = 1e38f;\ncontinue;\n@@ -319,11 +323,11 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nweight_high_value[i] = 1.0f;\n}\n- int decimation_mode = bsd->block_modes[i].decimation_mode;\n+ int decimation_mode = bm.decimation_mode;\n// compute weight bitcount for the mode\nint bits_used_by_weights = compute_ise_bitcount(ixtab2[decimation_mode]->num_weights,\n- (quantization_method) bsd->block_modes[i].quantization_mode);\n+ (quantization_method) bm.quantization_mode);\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n{\n@@ -338,7 +342,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * decimation_mode,\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * i,\nu8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * i,\n- bsd->block_modes[i].quantization_mode);\n+ bm.quantization_mode);\n// then, compute weight-errors for the weight mode.\nqwt_errors[i] = compute_error_of_weight_set(&(eix[decimation_mode]), ixtab2[decimation_mode], flt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * i);\n@@ -361,17 +365,21 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nuint8_t *u8_weight_src;\nint weights_to_copy;\n- if (quantized_weight[i] < 0)\n+ const int qw_packed_index = quantized_weight[i];\n+ if (qw_packed_index < 0)\n{\nscb->error_block = 1;\nscb++;\ncontinue;\n}\n- int decimation_mode = bsd->block_modes[quantized_weight[i]].decimation_mode;\n- int weight_quantization_mode = bsd->block_modes[quantized_weight[i]].quantization_mode;\n+ assert(qw_packed_index >= 0 && qw_packed_index < bsd->block_mode_packed_count);\n+ const block_mode& qw_bm = bsd->block_modes_packed[qw_packed_index];\n+\n+ int decimation_mode = qw_bm.decimation_mode;\n+ int weight_quantization_mode = qw_bm.quantization_mode;\nconst decimation_table *it = ixtab2[decimation_mode];\n- u8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * quantized_weight[i];\n+ u8_weight_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * qw_packed_index;\nweights_to_copy = it->num_weights;\n@@ -434,7 +442,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nscb->partition_count = partition_count;\nscb->partition_index = partition_index;\nscb->color_quantization_level = scb->color_formats_matched ? color_quantization_level_mod[i] : color_quantization_level[i];\n- scb->block_mode = quantized_weight[i];\n+ scb->block_mode = qw_bm.mode_index;\nscb->error_block = 0;\nif (scb->color_quantization_level < 4)\n@@ -617,15 +625,16 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nint qwt_bitcounts[MAX_WEIGHT_MODES];\nfloat qwt_errors[MAX_WEIGHT_MODES];\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\n- if (bsd->block_modes[i].permit_encode == 0 || bsd->block_modes[i].is_dual_plane != 1 || bsd->block_modes[i].percentile > mode_cutoff)\n+ const block_mode& bm = bsd->block_modes_packed[i];\n+ if (bm.is_dual_plane != 1 || bm.percentile > mode_cutoff)\n{\nqwt_errors[i] = 1e38f;\ncontinue;\n}\n- int decimation_mode = bsd->block_modes[i].decimation_mode;\n+ int decimation_mode = bm.decimation_mode;\nif (weight_high_value1[i] > 1.02f * min_wt_cutoff1)\n{\n@@ -639,7 +648,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\n// compute weight bitcount for the mode\nint bits_used_by_weights = compute_ise_bitcount(2 * ixtab2[decimation_mode]->num_weights,\n- (quantization_method) bsd->block_modes[i].quantization_mode);\n+ (quantization_method) bm.quantization_mode);\nint bitcount = free_bits_for_partition_count[partition_count] - bits_used_by_weights;\nif (bitcount <= 0 || bits_used_by_weights < 24 || bits_used_by_weights > 96)\n{\n@@ -655,7 +664,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nweight_high_value1[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * decimation_mode),\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i),\n- u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i), bsd->block_modes[i].quantization_mode);\n+ u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i), bm.quantization_mode);\ncompute_ideal_quantized_weights_for_decimation_table(\nixtab2[decimation_mode],\n@@ -663,7 +672,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nweight_high_value2[i],\ndecimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * decimation_mode + 1),\nflt_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i + 1),\n- u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i + 1), bsd->block_modes[i].quantization_mode);\n+ u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * i + 1), bm.quantization_mode);\n// then, compute quantization errors for the block mode.\n@@ -694,7 +703,8 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nfor (int i = 0; i < 4; i++)\n{\n- if (quantized_weight[i] < 0)\n+ const int qw_packed_index = quantized_weight[i];\n+ if (qw_packed_index < 0)\n{\nscb->error_block = 1;\nscb++;\n@@ -705,12 +715,15 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nuint8_t *u8_weight2_src;\nint weights_to_copy;\n- int decimation_mode = bsd->block_modes[quantized_weight[i]].decimation_mode;\n- int weight_quantization_mode = bsd->block_modes[quantized_weight[i]].quantization_mode;\n+ assert(qw_packed_index >= 0 && qw_packed_index < bsd->block_mode_packed_count);\n+ const block_mode& qw_bm = bsd->block_modes_packed[qw_packed_index];\n+\n+ int decimation_mode = qw_bm.decimation_mode;\n+ int weight_quantization_mode = qw_bm.quantization_mode;\nconst decimation_table *it = ixtab2[decimation_mode];\n- u8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * quantized_weight[i]);\n- u8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * quantized_weight[i] + 1);\n+ u8_weight1_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * qw_packed_index);\n+ u8_weight2_src = u8_quantized_decimated_quantized_weights + MAX_WEIGHTS_PER_BLOCK * (2 * qw_packed_index + 1);\nweights_to_copy = it->num_weights;\n@@ -777,7 +790,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\nscb->partition_count = partition_count;\nscb->partition_index = partition_index;\nscb->color_quantization_level = scb->color_formats_matched ? color_quantization_level_mod[i] : color_quantization_level[i];\n- scb->block_mode = quantized_weight[i];\n+ scb->block_mode = qw_bm.mode_index;\nscb->plane2_color_component = separate_component;\nscb->error_block = 0;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_decompress_symbolic.cpp", "new_path": "Source/astcenc_decompress_symbolic.cpp", "diff": "#include \"astcenc_internal.h\"\n#include <stdio.h>\n+#include <assert.h>\nstatic int compute_value_of_texel_int(\nint texel_to_get,\n@@ -206,11 +207,14 @@ void decompress_symbolic_block(\n// get the appropriate block descriptor\nconst decimation_table *const *ixtab2 = bsd->decimation_tables;\n- const decimation_table *it = ixtab2[bsd->block_modes[scb->block_mode].decimation_mode];\n+ const int packed_index = bsd->block_mode_to_packed[scb->block_mode];\n+ assert(packed_index >= 0 && packed_index < bsd->block_mode_packed_count);\n+ const block_mode& bm = bsd->block_modes_packed[packed_index];\n+ const decimation_table *it = ixtab2[bm.decimation_mode];\n- int is_dual_plane = bsd->block_modes[scb->block_mode].is_dual_plane;\n+ int is_dual_plane = bm.is_dual_plane;\n- int weight_quantization_level = bsd->block_modes[scb->block_mode].quantization_mode;\n+ int weight_quantization_level = bm.quantization_mode;\n// decode the color endpoints\nuint4 color_endpoint0[4];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -345,8 +345,7 @@ struct block_mode\nint8_t decimation_mode;\nint8_t quantization_mode;\nint8_t is_dual_plane;\n- int8_t permit_encode;\n- int8_t permit_decode;\n+ int16_t mode_index;\nfloat percentile;\n};\n@@ -364,7 +363,16 @@ struct block_size_descriptor\nfloat decimation_mode_percentile[MAX_DECIMATION_MODES];\nint permit_encode[MAX_DECIMATION_MODES];\nconst decimation_table *decimation_tables[MAX_DECIMATION_MODES];\n- block_mode block_modes[MAX_WEIGHT_MODES];\n+\n+ // out of all possible 2048 weight modes, only a subset is\n+ // actually valid for the current configuration (e.g. 6x6\n+ // 2D LDR has 370 valid modes); the valid ones are packed into\n+ // block_modes_packed array.\n+ block_mode block_modes_packed[MAX_WEIGHT_MODES];\n+ int block_mode_packed_count;\n+ // get index of block mode inside the block_modes_packed array,\n+ // or -1 if mode is not valid for the current configuration.\n+ int16_t block_mode_to_packed[MAX_WEIGHT_MODES];\n// for the k-means bed bitmap partitioning algorithm, we don't\n// want to consider more than 64 texels; this array specifies\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "#include \"astcenc_internal.h\"\n#include \"astcenc_vecmathlib.h\"\n+#include <assert.h>\n+\n/*\nfunctions to determine, for a given partitioning, which color endpoint formats are the best to use.\n*/\n@@ -818,13 +820,26 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nint best_quantization_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\n+ const int packed_mode_count = bsd->block_mode_packed_count;\n+ const int packed_mode_count_simd_up = (packed_mode_count + ASTCENC_SIMD_WIDTH - 1) / ASTCENC_SIMD_WIDTH * ASTCENC_SIMD_WIDTH;\n+ for (int i = packed_mode_count; i < packed_mode_count_simd_up; ++i)\n+ {\n+ errors_of_best_combination[i] = 1e30f;\n+ best_quantization_levels[i] = 0;\n+ best_quantization_levels_mod[i] = 0;\n+ }\n+#endif // #if ASTCENC_SIMD_WIDTH > 1\n+\n// code for the case where the block contains 1 partition\nif (partition_count == 1)\n{\nint best_quantization_level;\nint best_format;\nfloat error_of_best_combination;\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\nif (qwt_errors[i] >= 1e29f)\n{\n@@ -858,7 +873,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nbest_error, format_of_choice, combined_best_error, formats_of_choice);\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\nif (qwt_errors[i] >= 1e29f)\n{\n@@ -894,7 +909,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nthree_partitions_find_best_combination_for_every_quantization_and_integer_count(\nbest_error, format_of_choice, combined_best_error, formats_of_choice);\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\nif (qwt_errors[i] >= 1e29f)\n{\n@@ -931,7 +946,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nfour_partitions_find_best_combination_for_every_quantization_and_integer_count(\nbest_error, format_of_choice, combined_best_error, formats_of_choice);\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\nif (qwt_errors[i] >= 1e29f)\n{\n@@ -963,7 +978,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// reference; scalar code\nfloat best_ep_error = 1e30f;\nint best_error_index = -1;\n- for (int j = 0; j < MAX_WEIGHT_MODES; j++)\n+ for (int j = 0, npack = bsd->block_mode_packed_count; j < npack; ++j)\n{\nif (errors_of_best_combination[j] < best_ep_error && best_quantization_levels[j] >= 5)\n{\n@@ -977,7 +992,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nvint vbest_error_index(-1);\nvfloat vbest_ep_error(1e30f);\nvint lane_ids = vint::lane_id();\n- for (int j = 0; j < MAX_WEIGHT_MODES; j += ASTCENC_SIMD_WIDTH)\n+ for (int j = 0, npack = bsd->block_mode_packed_count; j < npack; j += ASTCENC_SIMD_WIDTH)\n{\nvfloat err = vfloat(&errors_of_best_combination[j]);\nvmask mask1 = err < vbest_ep_error;\n@@ -1013,6 +1028,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nif (quantized_weight[i] >= 0)\n{\nquantization_level[i] = best_quantization_levels[best_error_weights[i]];\n+ assert(quantization_level[i] >= 0 && quantization_level[i] < 21);\nquantization_level_mod[i] = best_quantization_levels_mod[best_error_weights[i]];\nfor (int j = 0; j < partition_count; j++)\n{\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+\n// routine to write up to 8 bits\nstatic inline void write_bits(\nint value,\n@@ -124,9 +126,13 @@ void symbolic_to_physical(\nconst decimation_table *const *ixtab2 = bsd.decimation_tables;\n- int weight_count = ixtab2[bsd.block_modes[scb.block_mode].decimation_mode]->num_weights;\n- int weight_quantization_method = bsd.block_modes[scb.block_mode].quantization_mode;\n- int is_dual_plane = bsd.block_modes[scb.block_mode].is_dual_plane;\n+ const int packed_index = bsd.block_mode_to_packed[scb.block_mode];\n+ assert(packed_index >= 0 && packed_index < bsd.block_mode_packed_count);\n+ const block_mode& bm = bsd.block_modes_packed[packed_index];\n+\n+ int weight_count = ixtab2[bm.decimation_mode]->num_weights;\n+ int weight_quantization_method = bm.quantization_mode;\n+ int is_dual_plane = bm.is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n@@ -321,15 +327,18 @@ void physical_to_symbolic(\nreturn;\n}\n- if (bsd.block_modes[block_mode].permit_decode == 0)\n+ const int packed_index = bsd.block_mode_to_packed[block_mode];\n+ if (packed_index < 0)\n{\nscb.error_block = 1;\nreturn;\n}\n+ assert(packed_index >= 0 && packed_index < bsd.block_mode_packed_count);\n+ const struct block_mode& bm = bsd.block_modes_packed[packed_index];\n- int weight_count = ixtab2[bsd.block_modes[block_mode].decimation_mode]->num_weights;\n- int weight_quantization_method = bsd.block_modes[block_mode].quantization_mode;\n- int is_dual_plane = bsd.block_modes[block_mode].is_dual_plane;\n+ int weight_count = ixtab2[bm.decimation_mode]->num_weights;\n+ int weight_quantization_method = bm.quantization_mode;\n+ int is_dual_plane = bm.is_dual_plane;\nint real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_weight_align.cpp", "new_path": "Source/astcenc_weight_align.cpp", "diff": "@@ -396,15 +396,16 @@ void compute_angular_endpoints_1plane(\ndecimated_weights + i * MAX_WEIGHTS_PER_BLOCK, quant_mode, low_values[i], high_values[i]);\n}\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\n- if (bsd->block_modes[i].is_dual_plane != 0 || bsd->block_modes[i].percentile > mode_cutoff)\n+ const block_mode& bm = bsd->block_modes_packed[i];\n+ if (bm.is_dual_plane != 0 || bm.percentile > mode_cutoff)\n{\ncontinue;\n}\n- int quant_mode = bsd->block_modes[i].quantization_mode;\n- int decim_mode = bsd->block_modes[i].decimation_mode;\n+ int quant_mode = bm.quantization_mode;\n+ int decim_mode = bm.decimation_mode;\nlow_value[i] = low_values[decim_mode][quant_mode];\nhigh_value[i] = high_values[decim_mode][quant_mode];\n@@ -448,15 +449,16 @@ void compute_angular_endpoints_2planes(\ndecimated_weights + (2 * i + 1) * MAX_WEIGHTS_PER_BLOCK, quant_mode, low_values2[i], high_values2[i]);\n}\n- for (int i = 0; i < MAX_WEIGHT_MODES; i++)\n+ for (int i = 0, ni = bsd->block_mode_packed_count; i < ni; ++i)\n{\n- if (bsd->block_modes[i].is_dual_plane != 1 || bsd->block_modes[i].percentile > mode_cutoff)\n+ const block_mode& bm = bsd->block_modes_packed[i];\n+ if (bm.is_dual_plane != 1 || bm.percentile > mode_cutoff)\n{\ncontinue;\n}\n- int quant_mode = bsd->block_modes[i].quantization_mode;\n- int decim_mode = bsd->block_modes[i].decimation_mode;\n+ int quant_mode = bm.quantization_mode;\n+ int decim_mode = bm.decimation_mode;\nlow_value1[i] = low_values1[decim_mode][quant_mode];\nhigh_value1[i] = high_values1[decim_mode][quant_mode];\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Densely pack valid block weight modes (#169) Densely pack valid block weight modes, since only a small subset of the 2048 are valid.
61,745
29.10.2020 20:16:33
0
c0b1f0e4b5da5256313c19fc030982832f408f31
Add utility to wrap Valgrind
[ { "change_type": "ADD", "old_path": null, "new_path": "Test/astc_profile_valgrind.py", "diff": "+#!/usr/bin/env python3\n+# SPDX-License-Identifier: Apache-2.0\n+# -----------------------------------------------------------------------------\n+# Copyright 2020 Arm Limited\n+#\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 simple wrapper utility to run a callgrind profile over a test image, and\n+post-process the output into an call graph image.\n+\n+Only runs on Linux and requires the following tools available on the PATH:\n+\n+ * valgrind\n+ * gprof2dot\n+ * dot\n+\"\"\"\n+\n+\n+import argparse\n+import os\n+import subprocess as sp\n+import sys\n+\n+def run_pass(image, encoder, blocksize, quality):\n+ \"\"\"\n+ Run Valgrind on a single binary.\n+\n+ Args:\n+ image (str): The path of the image to compress.\n+ encoder (str): The name of the encoder variant to run.\n+ blocksize (str): The block size to use.\n+ quality (str): The encoding quality to use.\n+\n+ Raises:\n+ CalledProcessException: Any subprocess failed.\n+ \"\"\"\n+ binary = \"./Source/astcenc-%s\" % encoder\n+ qualityFlag = \"-%s\" % quality\n+ args = [\"valgrind\", \"--tool=callgrind\", \"--callgrind-out-file=callgrind.txt\",\n+ binary, \"-cl\", image, \"out.astc\", blocksize, qualityFlag, \"-j\", \"1\"]\n+\n+ print(\" \".join(args))\n+ result = sp.run(args, check=True, universal_newlines=True)\n+\n+ args = [\"gprof2dot\", \"--format=callgrind\", \"--output=out.dot\", \"callgrind.txt\",\n+ \"-s\", \"-z\", \"compress_block(astcenc_context const&, astcenc_image const&, imageblock const*, symbolic_compressed_block&, physical_compressed_block&, compress_symbolic_block_buffers*)\"]\n+\n+ result = sp.run(args, check=True, universal_newlines=True)\n+\n+ args = [\"dot\", \"-Tpng\", \"out.dot\", \"-o\", \"%s.png\" % quality]\n+ result = sp.run(args, check=True, universal_newlines=True)\n+\n+ os.remove(\"out.astc\")\n+ os.remove(\"out.dot\")\n+ os.remove(\"callgrind.txt\")\n+\n+def parse_command_line():\n+ \"\"\"\n+ Parse the command line.\n+\n+ Returns:\n+ Namespace: The parsed command line container.\n+ \"\"\"\n+ parser = argparse.ArgumentParser()\n+\n+ parser.add_argument(\"img\", type=argparse.FileType(\"r\"),\n+ help=\"The image file to test\")\n+\n+ testencoders = [\"sse2\", \"sse4.2\", \"avx2\"]\n+ encoders = testencoders + [\"all\"]\n+ parser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\n+ choices=encoders, help=\"select encoder variant\")\n+\n+ testqualities = [\"fast\", \"medium\", \"thorough\"]\n+ qualities = testqualities + [\"all\"]\n+ parser.add_argument(\"--test-quality\", dest=\"qualities\", default=\"medium\",\n+ choices=qualities, help=\"select compression quality\")\n+\n+ args = parser.parse_args()\n+\n+ if args.encoders == \"all\":\n+ args.encoders = testencoders\n+ else:\n+ args.encoders = [args.encoders]\n+\n+ if args.qualities == \"all\":\n+ args.qualities = testqualities\n+ else:\n+ args.qualities = [args.qualities]\n+\n+ return args\n+\n+\n+def main():\n+ \"\"\"\n+ The main function.\n+\n+ Returns:\n+ int: The process return code.\n+ \"\"\"\n+ args = parse_command_line()\n+\n+ for quality in args.qualities:\n+ for encoder in args.encoders:\n+ run_pass(args.img.name, encoder, \"6x6\", quality)\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 utility to wrap Valgrind
61,745
30.10.2020 13:58:11
0
3f62b18667e7d57bbe20ce791630681c648a366c
Fix -*h and -*H inversion
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -81,12 +81,12 @@ static const mode_entry modes[] = {\n{\"-cs\", ASTCENC_OP_COMPRESS, ASTCENC_PRF_LDR_SRGB},\n{\"-ds\", ASTCENC_OP_DECOMPRESS, ASTCENC_PRF_LDR_SRGB},\n{\"-ts\", ASTCENC_OP_TEST, ASTCENC_PRF_LDR_SRGB},\n- {\"-ch\", ASTCENC_OP_COMPRESS, ASTCENC_PRF_HDR},\n- {\"-dh\", ASTCENC_OP_DECOMPRESS, ASTCENC_PRF_HDR},\n- {\"-th\", ASTCENC_OP_TEST, ASTCENC_PRF_HDR},\n- {\"-cH\", ASTCENC_OP_COMPRESS, ASTCENC_PRF_HDR_RGB_LDR_A},\n- {\"-dH\", ASTCENC_OP_DECOMPRESS, ASTCENC_PRF_HDR_RGB_LDR_A},\n- {\"-tH\", ASTCENC_OP_TEST, ASTCENC_PRF_HDR_RGB_LDR_A},\n+ {\"-ch\", ASTCENC_OP_COMPRESS, ASTCENC_PRF_HDR_RGB_LDR_A},\n+ {\"-dh\", ASTCENC_OP_DECOMPRESS, ASTCENC_PRF_HDR_RGB_LDR_A},\n+ {\"-th\", ASTCENC_OP_TEST, ASTCENC_PRF_HDR_RGB_LDR_A},\n+ {\"-cH\", ASTCENC_OP_COMPRESS, ASTCENC_PRF_HDR},\n+ {\"-dH\", ASTCENC_OP_DECOMPRESS, ASTCENC_PRF_HDR},\n+ {\"-tH\", ASTCENC_OP_TEST, ASTCENC_PRF_HDR},\n{\"-h\", ASTCENC_OP_HELP, ASTCENC_PRF_HDR},\n{\"-help\", ASTCENC_OP_HELP, ASTCENC_PRF_HDR},\n{\"-v\", ASTCENC_OP_VERSION, ASTCENC_PRF_HDR},\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix -*h and -*H inversion
61,745
30.10.2020 21:56:01
0
2270e5a2fae38a5f25a3fe22ac396d648213b2a1
Remove heuristic for three channel normals This heuristic has a high false-positive hit rate and slows down which slows down compression for non-normals.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -1043,12 +1043,10 @@ static float prepare_error_weight_block(\nreturn dot(error_weight_sum, float4(1.0f, 1.0f, 1.0f, 1.0f));\n}\n-static void prepare_block_statistics(\n+static float prepare_block_statistics(\nint texels_per_block,\nconst imageblock * blk,\n- const error_weight_block* ewb,\n- int* is_normal_map,\n- float* lowest_correl\n+ const error_weight_block* ewb\n) {\n// compute covariance matrix, as a collection of 10 scalars\n// (that form the upper-triangular row of the matrix; the matrix is\n@@ -1139,31 +1137,7 @@ static void prepare_block_statistics(\nlowest_correlation = MIN(lowest_correlation, fabsf(gb_cov));\nlowest_correlation = MIN(lowest_correlation, fabsf(ga_cov));\nlowest_correlation = MIN(lowest_correlation, fabsf(ba_cov));\n- *lowest_correl = lowest_correlation;\n-\n- // TODO: This looks like a broken attempt to have a heuristic for RGB\n- // three channel normals - check we actually handle this (later heuristics\n- // will treat them as X..Y which is not how the data is encoded).\n-\n- // compute a \"normal-map\" factor\n- // this factor should be exactly 0.0 for a normal map, while it may be all over the\n- // place for anything that is NOT a normal map. We can probably assume that a factor\n- // of less than 0.2f represents a normal map.\n-\n- float nf_sum = 0.0f;\n- for (int i = 0; i < texels_per_block; i++)\n- {\n- float3 val = float3(blk->data_r[i],\n- blk->data_g[i],\n- blk->data_b[i]);\n- val = val * (1.0f / 65535.0f);\n- val = (val - float3(0.5f, 0.5f, 0.5f)) * 2.0f;\n- float length_squared = dot(val, val);\n- float nf = fabsf(length_squared - 1.0f);\n- nf_sum += nf;\n- }\n-\n- *is_normal_map = nf_sum < (0.2f * (float)texels_per_block);\n+ return lowest_correlation;\n}\nvoid compress_block(\n@@ -1266,6 +1240,7 @@ void compress_block(\nmodecutoffs[0] = 0;\nmodecutoffs[1] = mode_cutoff;\n+ float lowest_correl;\nfloat best_errorval_in_mode;\nint start_trial = bsd->texel_count < TUNE_MIN_TEXELS_MODE0_FASTPATH ? 1 : 0;\n@@ -1305,14 +1280,7 @@ void compress_block(\n}\n}\n- int is_normal_map;\n- float lowest_correl;\n- prepare_block_statistics(bsd->texel_count, blk, ewb, &is_normal_map, &lowest_correl);\n-\n- if (is_normal_map && lowest_correl < 0.99f)\n- {\n- lowest_correl = 0.99f;\n- }\n+ lowest_correl = prepare_block_statistics(bsd->texel_count, blk, ewb);\n// next, test the four possible 1-partition, 2-planes modes\nfor (int i = 0; i < 4; i++)\n@@ -1416,7 +1384,7 @@ void compress_block(\n}\n}\n- if (partition_count == 2 && !is_normal_map && MIN(best_errorvals_in_modes[5], best_errorvals_in_modes[6]) > (best_errorvals_in_modes[0] * ctx.config.tune_partition_early_out_limit))\n+ if (partition_count == 2 && MIN(best_errorvals_in_modes[5], best_errorvals_in_modes[6]) > (best_errorvals_in_modes[0] * ctx.config.tune_partition_early_out_limit))\n{\ngoto END_OF_TESTS;\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove heuristic for three channel normals This heuristic has a high false-positive hit rate and slows down which slows down compression for non-normals.
61,745
31.10.2020 01:23:16
0
bc89d7885ec722e59c739b7359cc74e41be51c24
Make the number of trial candidates tunable Set the TUNE_TRIAL_CANDIDATES value in the astcenc_internal.h header to tune the number of candidates tested for each block mode. Reduce the count from 4 to 2, which costs ~0.05dB, but gains 6-12% performance across all images.
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -351,16 +351,16 @@ static void compress_symbolic_block_fixed_partition_1_plane(\n// for each weighting mode, determine the optimal combination of color endpoint encodings\n// and weight encodings; return results for the 4 best-looking modes.\n- int partition_format_specifiers[4][4];\n- int quantized_weight[4];\n- int color_quantization_level[4];\n- int color_quantization_level_mod[4];\n+ int partition_format_specifiers[TUNE_TRIAL_CANDIDATES][4];\n+ int quantized_weight[TUNE_TRIAL_CANDIDATES];\n+ int color_quantization_level[TUNE_TRIAL_CANDIDATES];\n+ int color_quantization_level_mod[TUNE_TRIAL_CANDIDATES];\ndetermine_optimal_set_of_endpoint_formats_to_use(bsd, pi, blk, ewb, &(ei->ep), -1, // used to flag that we are in single-weight mode\nqwt_bitcounts, qwt_errors, partition_format_specifiers, quantized_weight, color_quantization_level, color_quantization_level_mod);\n// then iterate over the 4 believed-to-be-best modes to find out which one is\n// actually best.\n- for (int i = 0; i < 4; i++)\n+ for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n{\nuint8_t *u8_weight_src;\nint weights_to_copy;\n@@ -687,10 +687,10 @@ static void compress_symbolic_block_fixed_partition_2_planes(\n}\n// decide the optimal combination of color endpoint encodings and weight encodings.\n- int partition_format_specifiers[4][4];\n- int quantized_weight[4];\n- int color_quantization_level[4];\n- int color_quantization_level_mod[4];\n+ int partition_format_specifiers[TUNE_TRIAL_CANDIDATES][4];\n+ int quantized_weight[TUNE_TRIAL_CANDIDATES];\n+ int color_quantization_level[TUNE_TRIAL_CANDIDATES];\n+ int color_quantization_level_mod[TUNE_TRIAL_CANDIDATES];\nendpoints epm;\nmerge_endpoints(&(ei1->ep), &(ei2->ep), separate_component, &epm);\n@@ -701,7 +701,7 @@ static void compress_symbolic_block_fixed_partition_2_planes(\npartition_format_specifiers, quantized_weight,\ncolor_quantization_level, color_quantization_level_mod);\n- for (int i = 0; i < 4; i++)\n+ for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n{\nconst int qw_packed_index = quantized_weight[i];\nif (qw_packed_index < 0)\n@@ -1238,7 +1238,7 @@ void compress_block(\nfloat lowest_correl;\nfloat best_errorval_in_mode;\n- int start_trial = bsd->texel_count < TUNE_MIN_TEXELS_MODE0_FASTPATH ? 1 : 0;\n+ int start_trial = bsd->texel_count < TUNE_MAX_TEXELS_MODE0_FASTPATH ? 1 : 0;\nfor (int i = start_trial; i < 2; i++)\n{\ncompress_symbolic_block_fixed_partition_1_plane(decode_mode, modecutoffs[i], ctx.config.tune_refinement_limit, bsd, 1, // partition count\n@@ -1246,7 +1246,7 @@ void compress_block(\nblk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < 4; j++)\n+ for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n{\nif (tempblocks[j].error_block)\n{\n@@ -1303,7 +1303,7 @@ void compress_block(\nblk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < 4; j++)\n+ for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n{\nif (tempblocks[j].error_block)\n{\n@@ -1350,7 +1350,7 @@ void compress_block(\nbsd, partition_count, partition_indices_1plane[i], blk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < 4; j++)\n+ for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n{\nif (tempblocks[j].error_block)\n{\n@@ -1407,7 +1407,7 @@ void compress_block(\nblk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < 4; j++)\n+ for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n{\nif (tempblocks[j].error_block)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "#include \"astcenc.h\"\n#include \"astcenc_mathlib.h\"\n-// ASTC parameters\n+/* ============================================================================\n+ Constants\n+============================================================================ */\n#define MAX_TEXELS_PER_BLOCK 216\n#define MAX_WEIGHTS_PER_BLOCK 64\n#define MIN_WEIGHT_BITS_PER_BLOCK 24\n#define MAX_DECIMATION_MODES 87\n#define MAX_WEIGHT_MODES 2048\n-// Compile-time tuning parameters\n-static const int TUNE_MIN_TEXELS_MODE0_FASTPATH { 25 };\n-\n// A high default error value\nstatic const float ERROR_CALC_DEFAULT { 1e30f };\n-// uncomment this macro to enable checking for inappropriate NaNs;\n-// works on Linux only, and slows down encoding significantly.\n+/* ============================================================================\n+ Compile-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 int TUNE_MAX_TEXELS_MODE0_FASTPATH { 24 };\n+\n+// The number of candidate encodings returned for each encoding mode.\n+// Default: 2, which sacrifices ~0.05dB vs 4 to gain ~10% performance\n+static const int TUNE_TRIAL_CANDIDATES { 2 };\n+\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@@ -1037,7 +1050,7 @@ struct alignas(ASTCENC_VECALIGN) compress_fixed_partition_buffers\nstruct compress_symbolic_block_buffers\n{\nerror_weight_block ewb;\n- symbolic_compressed_block tempblocks[4];\n+ symbolic_compressed_block tempblocks[TUNE_TRIAL_CANDIDATES];\ncompress_fixed_partition_buffers planes;\n};\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -757,7 +757,7 @@ static void four_partitions_find_best_combination_for_bitcount(\nThe determine_optimal_set_of_endpoint_formats_to_use() function.\nIt identifies, for each mode, which set of color endpoint encodings\n- produces the best overall result. It then reports back which 4 modes\n+ produces the best overall result. It then reports back which TUNE_TRIAL_CANDIDATES modes\nlook best, along with the ideal color encoding combination for each.\nIt takes as input:\n@@ -766,7 +766,7 @@ static void four_partitions_find_best_combination_for_bitcount(\nfor each mode, the number of bits available for color encoding and the error incurred by quantization.\nin case of 2 plane of weights, a specifier for which color component to use for the second plane of weights.\n- It delivers as output for each of the 4 selected modes:\n+ It delivers as output for each of the TUNE_TRIAL_CANDIDATES selected modes:\nformat specifier\nfor each partition\nquantization level to use\n@@ -784,10 +784,10 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n// output data\n- int partition_format_specifiers[4][4],\n- int quantized_weight[4],\n- int quantization_level[4],\n- int quantization_level_mod[4]\n+ int partition_format_specifiers[TUNE_TRIAL_CANDIDATES][4],\n+ int quantized_weight[TUNE_TRIAL_CANDIDATES],\n+ int quantization_level[TUNE_TRIAL_CANDIDATES],\n+ int quantization_level_mod[TUNE_TRIAL_CANDIDATES]\n) {\nint partition_count = pt->partition_count;\n@@ -953,6 +953,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\nerrors_of_best_combination[i] = 1e30f;\ncontinue;\n}\n+\nfour_partitions_find_best_combination_for_bitcount(\ncombined_best_error, formats_of_choice, qwt_bitcounts[i],\n&best_quantization_level, &best_quantization_level_mod,\n@@ -970,9 +971,9 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n}\n}\n- // finally, go through the results and pick the 4 best-looking modes.\n- int best_error_weights[4];\n- for (int i = 0; i < 4; i++)\n+ // finally, go through the results and pick the TUNE_TRIAL_CANDIDATES best-looking modes.\n+ int best_error_weights[TUNE_TRIAL_CANDIDATES];\n+ for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n{\n#if 0\n// reference; scalar code\n@@ -1022,7 +1023,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n}\n}\n- for (int i = 0; i < 4; i++)\n+ for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n{\nquantized_weight[i] = best_error_weights[i];\nif (quantized_weight[i] >= 0)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make the number of trial candidates tunable Set the TUNE_TRIAL_CANDIDATES value in the astcenc_internal.h header to tune the number of candidates tested for each block mode. Reduce the count from 4 to 2, which costs ~0.05dB, but gains 6-12% performance across all images.
61,745
31.10.2020 15:48:18
0
99d0f68db6dd4b7831026b7d77bcec6d419a12c3
Expose candidate limit as power user CLI option
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -433,6 +433,13 @@ struct astcenc_config {\n*/\nunsigned int tune_refinement_limit;\n+ /**\n+ * @brief The number of trial candidates per mode search (-candidatelimit).\n+ *\n+ * Valid values are between 1 and TUNE_MAX_TRIAL_CANDIDATES (default 4).\n+ */\n+ unsigned int tune_candidate_limit;\n+\n/**\n* @brief The dB threshold for stopping block search (-dblimit).\n*\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -213,6 +213,7 @@ static int realign_weights(\nstatic void compress_symbolic_block_fixed_partition_1_plane(\nastcenc_profile decode_mode,\nfloat mode_cutoff,\n+ int tune_candidate_limit,\nint max_refinement_iters,\nconst block_size_descriptor* bsd,\nint partition_count, int partition_index,\n@@ -351,16 +352,18 @@ static void compress_symbolic_block_fixed_partition_1_plane(\n// for each weighting mode, determine the optimal combination of color endpoint encodings\n// and weight encodings; return results for the 4 best-looking modes.\n- int partition_format_specifiers[TUNE_TRIAL_CANDIDATES][4];\n- int quantized_weight[TUNE_TRIAL_CANDIDATES];\n- int color_quantization_level[TUNE_TRIAL_CANDIDATES];\n- int color_quantization_level_mod[TUNE_TRIAL_CANDIDATES];\n- determine_optimal_set_of_endpoint_formats_to_use(bsd, pi, blk, ewb, &(ei->ep), -1, // used to flag that we are in single-weight mode\n- qwt_bitcounts, qwt_errors, partition_format_specifiers, quantized_weight, color_quantization_level, color_quantization_level_mod);\n+ int partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4];\n+ int quantized_weight[TUNE_MAX_TRIAL_CANDIDATES];\n+ int color_quantization_level[TUNE_MAX_TRIAL_CANDIDATES];\n+ int color_quantization_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\n+ determine_optimal_set_of_endpoint_formats_to_use(\n+ bsd, pi, blk, ewb, &(ei->ep), -1, qwt_bitcounts, qwt_errors,\n+ tune_candidate_limit, partition_format_specifiers, quantized_weight,\n+ color_quantization_level, color_quantization_level_mod);\n- // then iterate over the 4 believed-to-be-best modes to find out which one is\n- // actually best.\n- for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n+ // then iterate over the tune_candidate_limit believed-to-be-best modes to\n+ // find out which one is actually best.\n+ for (int i = 0; i < tune_candidate_limit; i++)\n{\nuint8_t *u8_weight_src;\nint weights_to_copy;\n@@ -472,6 +475,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\nstatic void compress_symbolic_block_fixed_partition_2_planes(\nastcenc_profile decode_mode,\nfloat mode_cutoff,\n+ int tune_candidate_limit,\nint max_refinement_iters,\nconst block_size_descriptor* bsd,\nint partition_count,\n@@ -687,21 +691,20 @@ static void compress_symbolic_block_fixed_partition_2_planes(\n}\n// decide the optimal combination of color endpoint encodings and weight encodings.\n- int partition_format_specifiers[TUNE_TRIAL_CANDIDATES][4];\n- int quantized_weight[TUNE_TRIAL_CANDIDATES];\n- int color_quantization_level[TUNE_TRIAL_CANDIDATES];\n- int color_quantization_level_mod[TUNE_TRIAL_CANDIDATES];\n+ int partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4];\n+ int quantized_weight[TUNE_MAX_TRIAL_CANDIDATES];\n+ int color_quantization_level[TUNE_MAX_TRIAL_CANDIDATES];\n+ int color_quantization_level_mod[TUNE_MAX_TRIAL_CANDIDATES];\nendpoints epm;\nmerge_endpoints(&(ei1->ep), &(ei2->ep), separate_component, &epm);\ndetermine_optimal_set_of_endpoint_formats_to_use(\n- bsd, pi, blk, ewb,\n- &epm, separate_component, qwt_bitcounts, qwt_errors,\n- partition_format_specifiers, quantized_weight,\n+ bsd, pi, blk, ewb, &epm, separate_component, qwt_bitcounts, qwt_errors,\n+ tune_candidate_limit, partition_format_specifiers, quantized_weight,\ncolor_quantization_level, color_quantization_level_mod);\n- for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n+ for (int i = 0; i < tune_candidate_limit; i++)\n{\nconst int qw_packed_index = quantized_weight[i];\nif (qw_packed_index < 0)\n@@ -1241,12 +1244,14 @@ void compress_block(\nint start_trial = bsd->texel_count < TUNE_MAX_TEXELS_MODE0_FASTPATH ? 1 : 0;\nfor (int i = start_trial; i < 2; i++)\n{\n- compress_symbolic_block_fixed_partition_1_plane(decode_mode, modecutoffs[i], ctx.config.tune_refinement_limit, bsd, 1, // partition count\n- 0, // partition index\n- blk, ewb, tempblocks, &tmpbuf->planes);\n+ compress_symbolic_block_fixed_partition_1_plane(\n+ decode_mode, modecutoffs[i],\n+ ctx.config.tune_candidate_limit,\n+ ctx.config.tune_refinement_limit,\n+ bsd, 1, 0, blk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n+ for (unsigned int j = 0; j < ctx.config.tune_candidate_limit; j++)\n{\nif (tempblocks[j].error_block)\n{\n@@ -1296,14 +1301,17 @@ void compress_block(\ncontinue;\n}\n- compress_symbolic_block_fixed_partition_2_planes(decode_mode, mode_cutoff, ctx.config.tune_refinement_limit,\n+ compress_symbolic_block_fixed_partition_2_planes(\n+ decode_mode, mode_cutoff,\n+ ctx.config.tune_candidate_limit,\n+ ctx.config.tune_refinement_limit,\nbsd, 1, // partition count\n0, // partition index\ni, // the color component to test a separate plane of weights for.\nblk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n+ for (unsigned int j = 0; j < ctx.config.tune_candidate_limit; j++)\n{\nif (tempblocks[j].error_block)\n{\n@@ -1346,11 +1354,15 @@ void compress_block(\nfor (int i = 0; i < 2; i++)\n{\n- compress_symbolic_block_fixed_partition_1_plane(decode_mode, mode_cutoff, ctx.config.tune_refinement_limit,\n- bsd, partition_count, partition_indices_1plane[i], blk, ewb, tempblocks, &tmpbuf->planes);\n+ compress_symbolic_block_fixed_partition_1_plane(\n+ decode_mode, mode_cutoff,\n+ ctx.config.tune_candidate_limit,\n+ ctx.config.tune_refinement_limit,\n+ bsd, partition_count, partition_indices_1plane[i],\n+ blk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n+ for (unsigned int j = 0; j < ctx.config.tune_candidate_limit; j++)\n{\nif (tempblocks[j].error_block)\n{\n@@ -1398,16 +1410,19 @@ void compress_block(\nif (lowest_correl <= ctx.config.tune_two_plane_early_out_limit)\n{\n- compress_symbolic_block_fixed_partition_2_planes(decode_mode,\n+ compress_symbolic_block_fixed_partition_2_planes(\n+ decode_mode,\nmode_cutoff,\n+ ctx.config.tune_candidate_limit,\nctx.config.tune_refinement_limit,\nbsd,\npartition_count,\n- partition_index_2planes & (PARTITION_COUNT - 1), partition_index_2planes >> PARTITION_BITS,\n+ partition_index_2planes & (PARTITION_COUNT - 1),\n+ partition_index_2planes >> PARTITION_BITS,\nblk, ewb, tempblocks, &tmpbuf->planes);\nbest_errorval_in_mode = 1e30f;\n- for (int j = 0; j < TUNE_TRIAL_CANDIDATES; j++)\n+ for (unsigned int j = 0; j < ctx.config.tune_candidate_limit; j++)\n{\nif (tempblocks[j].error_block)\n{\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -249,6 +249,7 @@ static astcenc_error validate_config(\nconfig.tune_partition_limit = astc::clampi(config.tune_partition_limit, 1, PARTITION_COUNT);\nconfig.tune_block_mode_limit = astc::clampi(config.tune_block_mode_limit, 1, 100);\nconfig.tune_refinement_limit = MAX(config.tune_refinement_limit, 1);\n+ config.tune_candidate_limit = astc::clampi(config.tune_candidate_limit, 1, TUNE_MAX_TRIAL_CANDIDATES);\nconfig.tune_db_limit = MAX(config.tune_db_limit, 0.0f);\nconfig.tune_partition_early_out_limit = MAX(config.tune_partition_early_out_limit, 0.0f);\nconfig.tune_two_plane_early_out_limit = MAX(config.tune_two_plane_early_out_limit, 0.0f);\n@@ -311,6 +312,7 @@ astcenc_error astcenc_config_init(\nconfig.tune_partition_limit = 4;\nconfig.tune_block_mode_limit = 50;\nconfig.tune_refinement_limit = 1;\n+ config.tune_candidate_limit = MIN(2, TUNE_MAX_TRIAL_CANDIDATES);\nconfig.tune_db_limit = MAX(85 - 35 * ltexels, 63 - 19 * ltexels);\nconfig.tune_partition_early_out_limit = 1.0f;\nconfig.tune_two_plane_early_out_limit = 0.5f;\n@@ -319,6 +321,7 @@ astcenc_error astcenc_config_init(\nconfig.tune_partition_limit = 25;\nconfig.tune_block_mode_limit = 75;\nconfig.tune_refinement_limit = 2;\n+ config.tune_candidate_limit = MIN(2, TUNE_MAX_TRIAL_CANDIDATES);\nconfig.tune_db_limit = MAX(95 - 35 * ltexels, 70 - 19 * ltexels);\nconfig.tune_partition_early_out_limit = 1.2f;\nconfig.tune_two_plane_early_out_limit = 0.75f;\n@@ -327,6 +330,7 @@ astcenc_error astcenc_config_init(\nconfig.tune_partition_limit = 100;\nconfig.tune_block_mode_limit = 95;\nconfig.tune_refinement_limit = 4;\n+ config.tune_candidate_limit = MIN(3, TUNE_MAX_TRIAL_CANDIDATES);\nconfig.tune_db_limit = MAX(105 - 35 * ltexels, 77 - 19 * ltexels);\nconfig.tune_partition_early_out_limit = 2.5f;\nconfig.tune_two_plane_early_out_limit = 0.95f;\n@@ -335,6 +339,7 @@ astcenc_error astcenc_config_init(\nconfig.tune_partition_limit = 1024;\nconfig.tune_block_mode_limit = 100;\nconfig.tune_refinement_limit = 4;\n+ config.tune_candidate_limit = MIN(4, TUNE_MAX_TRIAL_CANDIDATES);\nconfig.tune_db_limit = 999.0f;\nconfig.tune_partition_early_out_limit = 1000.0f;\nconfig.tune_two_plane_early_out_limit = 0.99f;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "@@ -71,9 +71,9 @@ static const float ERROR_CALC_DEFAULT { 1e30f };\n// Default: enabled for 4x4 and 5x4 blocks.\nstatic const int TUNE_MAX_TEXELS_MODE0_FASTPATH { 24 };\n-// The number of candidate encodings returned for each encoding mode.\n-// Default: 2, which sacrifices ~0.05dB vs 4 to gain ~10% performance\n-static const int TUNE_TRIAL_CANDIDATES { 2 };\n+// The maximum number of candidate encodings returned for each encoding mode.\n+// Default: depends on quality preset\n+static const int TUNE_MAX_TRIAL_CANDIDATES { 4 };\n/* ============================================================================\nOther configuration parameters\n@@ -1050,7 +1050,7 @@ struct alignas(ASTCENC_VECALIGN) compress_fixed_partition_buffers\nstruct compress_symbolic_block_buffers\n{\nerror_weight_block ewb;\n- symbolic_compressed_block tempblocks[TUNE_TRIAL_CANDIDATES];\n+ symbolic_compressed_block tempblocks[TUNE_MAX_TRIAL_CANDIDATES];\ncompress_fixed_partition_buffers planes;\n};\n@@ -1072,6 +1072,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n+ int tune_candidate_limit,\n// output data\nint partition_format_specifiers[4][4],\nint quantized_weight[4],\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_pick_best_endpoint_format.cpp", "new_path": "Source/astcenc_pick_best_endpoint_format.cpp", "diff": "@@ -757,8 +757,9 @@ static void four_partitions_find_best_combination_for_bitcount(\nThe determine_optimal_set_of_endpoint_formats_to_use() function.\nIt identifies, for each mode, which set of color endpoint encodings\n- produces the best overall result. It then reports back which TUNE_TRIAL_CANDIDATES modes\n- look best, along with the ideal color encoding combination for each.\n+ produces the best overall result. It then reports back which\n+ tune_candidate_limit, modes look best, along with the ideal color encoding\n+ combination for each.\nIt takes as input:\na partitioning an imageblock,\n@@ -766,7 +767,7 @@ static void four_partitions_find_best_combination_for_bitcount(\nfor each mode, the number of bits available for color encoding and the error incurred by quantization.\nin case of 2 plane of weights, a specifier for which color component to use for the second plane of weights.\n- It delivers as output for each of the TUNE_TRIAL_CANDIDATES selected modes:\n+ It delivers as output for each of the tune_candidate_limit selected modes:\nformat specifier\nfor each partition\nquantization level to use\n@@ -783,11 +784,12 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n// bitcounts and errors computed for the various quantization methods\nconst int* qwt_bitcounts,\nconst float* qwt_errors,\n+ int tune_candidate_limit,\n// output data\n- int partition_format_specifiers[TUNE_TRIAL_CANDIDATES][4],\n- int quantized_weight[TUNE_TRIAL_CANDIDATES],\n- int quantization_level[TUNE_TRIAL_CANDIDATES],\n- int quantization_level_mod[TUNE_TRIAL_CANDIDATES]\n+ int partition_format_specifiers[TUNE_MAX_TRIAL_CANDIDATES][4],\n+ int quantized_weight[TUNE_MAX_TRIAL_CANDIDATES],\n+ int quantization_level[TUNE_MAX_TRIAL_CANDIDATES],\n+ int quantization_level_mod[TUNE_MAX_TRIAL_CANDIDATES]\n) {\nint partition_count = pt->partition_count;\n@@ -971,9 +973,9 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n}\n}\n- // finally, go through the results and pick the TUNE_TRIAL_CANDIDATES best-looking modes.\n- int best_error_weights[TUNE_TRIAL_CANDIDATES];\n- for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n+ // finally, go through the results and pick the best-looking modes.\n+ int best_error_weights[TUNE_MAX_TRIAL_CANDIDATES];\n+ for (int i = 0; i < tune_candidate_limit; i++)\n{\n#if 0\n// reference; scalar code\n@@ -1023,7 +1025,7 @@ void determine_optimal_set_of_endpoint_formats_to_use(\n}\n}\n- for (int i = 0; i < TUNE_TRIAL_CANDIDATES; i++)\n+ for (int i = 0; i < tune_candidate_limit; i++)\n{\nquantized_weight[i] = best_error_weights[i];\nif (quantized_weight[i] >= 0)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -765,6 +765,17 @@ int edit_astcenc_config(\nconfig.tune_refinement_limit = atoi(argv[argidx - 1]);\n}\n+ else if (!strcmp(argv[argidx], \"-candidatelimit\"))\n+ {\n+ argidx += 2;\n+ if (argidx > argc)\n+ {\n+ printf(\"ERROR: -candidatelimit switch with no argument\\n\");\n+ return 1;\n+ }\n+\n+ config.tune_candidate_limit = atoi(argv[argidx - 1]);\n+ }\nelse if (!strcmp(argv[argidx], \"-j\"))\n{\nargidx += 2;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -298,6 +298,14 @@ ADVANCED COMPRESSION\n-thorough : 4\n-exhaustive : 4\n+ -candidatelimit <value>\n+ Trial only <value> candidate encodings for each block mode:\n+\n+ -fast : 2\n+ -medium : 2\n+ -thorough : 3\n+ -exhaustive : 4\n+\n-dblimit <number>\nStop compression work on a block as soon as the PSNR of the\nblock, measured in dB, exceeds <number>. This option is\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -1091,7 +1091,6 @@ class CLIPTest(CLITestBase):\ninputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\ndecompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n- # Compute the basic image without any channel weights\ncommand = [\nself.binary, \"-tl\",\ninputFile, decompFile, \"4x4\", \"-medium\"]\n@@ -1106,6 +1105,27 @@ class CLIPTest(CLITestBase):\n# RMSE should get worse (higher) if we reduce search space\nself.assertGreater(testRMSE, refRMSE)\n+ def test_candidate_limit(self):\n+ \"\"\"\n+ Test candidate limit.\n+ \"\"\"\n+ inputFile = \"./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png\"\n+ decompFile = self.get_tmp_image_path(\"LDR\", \"decomp\")\n+\n+ command = [\n+ self.binary, \"-tl\",\n+ inputFile, decompFile, \"4x4\", \"-medium\"]\n+\n+ self.exec(command)\n+ refRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n+\n+ command += [\"-candidatelimit\", \"1\"]\n+ self.exec(command)\n+ testRMSE = sum(self.get_channel_rmse(inputFile, decompFile))\n+\n+ # RMSE should get worse (higher) if we reduce search space\n+ self.assertGreater(testRMSE, refRMSE)\n+\ndef test_db_cutoff_limit(self):\n\"\"\"\nTest db cutoff limit.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Expose candidate limit as power user CLI option
61,745
31.10.2020 16:10:19
0
91a185f55cad03068c01c38284e7cd2ccfb1cbb7
Readd a low quality -fastest preset
[ { "change_type": "MODIFY", "old_path": "Source/astcenc.h", "new_path": "Source/astcenc.h", "diff": "@@ -212,13 +212,15 @@ enum astcenc_profile {\n* @brief A codec quality preset.\n*/\nenum astcenc_preset {\n- /** @brief The fast, lowest quality, search preset. */\n- ASTCENC_PRE_FAST = 0,\n+ /** @brief The fastest, lowest quality, search preset. */\n+ ASTCENC_PRE_FASTEST = 0,\n+ /** @brief The fast search preset. */\n+ ASTCENC_PRE_FAST,\n/** @brief The medium quality search preset. */\nASTCENC_PRE_MEDIUM,\n/** @brief The throrough quality search preset. */\nASTCENC_PRE_THOROUGH,\n- /** @brief The exhaustive quality search preset. */\n+ /** @brief The exhaustive, highest quality, search preset. */\nASTCENC_PRE_EXHAUSTIVE\n};\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_entry.cpp", "new_path": "Source/astcenc_entry.cpp", "diff": "@@ -308,6 +308,15 @@ astcenc_error astcenc_config_init(\n// may replace some of these settings with more use case tuned values\nswitch(preset)\n{\n+ case ASTCENC_PRE_FASTEST:\n+ config.tune_partition_limit = 2;\n+ config.tune_block_mode_limit = 25;\n+ config.tune_refinement_limit = 1;\n+ config.tune_candidate_limit = MIN(1, TUNE_MAX_TRIAL_CANDIDATES);\n+ config.tune_db_limit = MAX(70 - 35 * ltexels, 53 - 19 * ltexels);\n+ config.tune_partition_early_out_limit = 1.0f;\n+ config.tune_two_plane_early_out_limit = 0.5f;\n+ break;\ncase ASTCENC_PRE_FAST:\nconfig.tune_partition_limit = 4;\nconfig.tune_block_mode_limit = 50;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -396,7 +396,11 @@ int init_astcenc_config(\nreturn 1;\n}\n- if (!strcmp(argv[5], \"-fast\"))\n+ if (!strcmp(argv[5], \"-fastest\"))\n+ {\n+ preset = ASTCENC_PRE_FASTEST;\n+ }\n+ else if (!strcmp(argv[5], \"-fast\"))\n{\npreset = ASTCENC_PRE_FAST;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -139,12 +139,17 @@ COMPRESSION\nimage quality at the expense of compression time. The available\npresets are:\n+ -fastest\n-fast\n-medium\n-thorough\n-exhaustive\n- Note that using -exhaustive significantly increases compression\n+ Using the -fastest setting throws away a lot of image quality\n+ compared. It is useful for quickly roughing-out new content, but\n+ we recommend using higher quality settings for production builds.\n+\n+ Using the -exhaustive setting significantly increases compression\ntime, but typically only gives minor quality improvements over\nusing -thorough.\n@@ -274,6 +279,7 @@ ADVANCED COMPRESSION\nbetter quality, however large values give diminishing returns\nespecially for smaller block sizes. Preset defaults are:\n+ -fastest : 2\n-fast : 4\n-medium : 25\n-thorough : 100\n@@ -284,6 +290,7 @@ ADVANCED COMPRESSION\nempirically determined distribution of block mode frequency.\nThis option is ineffective for 3D textures. Preset defaults are:\n+ -fastest : 25\n-fast : 50\n-medium : 75\n-thorough : 95\n@@ -293,6 +300,7 @@ ADVANCED COMPRESSION\nIterate only <value> refinement iterations on colors and\nweights. Minimum value is 1. Preset defaults are:\n+ -fastest : 1\n-fast : 1\n-medium : 2\n-thorough : 4\n@@ -301,6 +309,7 @@ ADVANCED COMPRESSION\n-candidatelimit <value>\nTrial only <value> candidate encodings for each block mode:\n+ -fastest : 1\n-fast : 2\n-medium : 2\n-thorough : 3\n@@ -312,10 +321,11 @@ ADVANCED COMPRESSION\nineffective for HDR textures. Preset defaults, where N is the\nnumber of texels in a block, are:\n- -fast : dblimit = MAX(63-19*log10(N), 85-35*log10(N))\n- -medium : dblimit = MAX(70-19*log10(N), 95-35*log10(N))\n- -thorough : dblimit = MAX(77-19*log10(N), 105-35*log10(N))\n- -exhaustive : dblimit = 999\n+ -fastest : MAX(53-19*log10(N), 70-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+ -exhaustive : 999\n-partitionearlylimit <factor>\nStop compression work on a block after only testing blocks with\n@@ -324,6 +334,7 @@ ADVANCED COMPRESSION\nwith one partition by more than the specified factor. This\noption is ineffective for normal maps. Preset defaults are:\n+ -fastest : 1.0\n-fast : 1.0\n-medium : 1.2\n-thorough : 2.5\n@@ -335,6 +346,7 @@ ADVANCED COMPRESSION\ncolor channels is below this factor. This option is ineffective\nfor normal maps. Preset defaults are:\n+ -fastest : 0.50\n-fast : 0.50\n-medium : 0.75\n-thorough : 0.95\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_functional.py", "new_path": "Test/astc_test_functional.py", "diff": "@@ -647,7 +647,7 @@ class CLIPTest(CLITestBase):\n\"\"\"\nTest all valid presets are accepted\n\"\"\"\n- presets = [\"-fast\", \"-medium\", \"-thorough\", \"-exhaustive\"]\n+ presets = [\"-fastest\", \"-fast\", \"-medium\", \"-thorough\", \"-exhaustive\"]\nimIn = self.get_ref_image_path(\"LDR\", \"input\", \"A\")\nimOut = self.get_tmp_image_path(\"LDR\", \"decomp\")\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -57,7 +57,7 @@ else:\nTEST_BLOCK_SIZES = [\"4x4\", \"5x5\", \"6x6\", \"8x8\", \"12x12\",\n\"3x3x3\", \"6x6x6\"]\n-TEST_QUALITIES = [\"fast\", \"medium\", \"thorough\"]\n+TEST_QUALITIES = [\"fastest\", \"fast\", \"medium\", \"thorough\"]\ndef is_3d(blockSize):\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Readd a low quality -fastest preset
61,745
31.10.2020 16:43:28
0
0513fb9cfb789d791dc453e84439f7fd9338e7dc
Add -fastest to readme
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -36,7 +36,8 @@ dynamic range (BMP, PNG, TGA), high dynamic range (EXR, HDR), or DDS and KTX\nwrapped output images.\nThe encoder allows control over the compression time/quality tradeoff with\n-`exhaustive`, `thorough`, `medium`, and `fast` encoding quality presets.\n+`exhaustive`, `thorough`, `medium`, `fast`, and `fastest` encoding quality\n+presets.\nThe encoder allows compression time and quality analysis by reporting the\ncompression time, and the Peak Signal-to-Noise Ratio (PSNR) between the input\n@@ -172,10 +173,15 @@ recommend experimenting with the block footprint to find the optimum balance\nbetween size and quality, as the finely adjustable compression ratio is one of\nmajor strengths of the ASTC format.\n-The compression speed can be controlled from `-fast`, through `-medium` and\n-`-thorough`, up to `-exhaustive`. In general, the more time the encoder has to\n-spend looking for good encodings the better the results, but it does result in\n-increasingly small improvements for the amount of time required.\n+The compression speed can be controlled from `-fastest`, through `-fast`,\n+`-medium` and `-thorough`, up to `-exhaustive`. In general, the more time the\n+encoder has to spend looking for good encodings the better the results, but it\n+does result in increasingly small improvements for the amount of time required.\n+\n+:warning: The `-fastest` quality preset is designed for quickly roughing-out\n+new content. It is tuned to give the fastest possible compression, often at the\n+expense of significant image quality loss compared to `-fast`. We do not\n+recommend using it for production builds.\nThere are many other command line options for tuning the encoder parameters\nwhich can be used to fine tune the compression algorithm. See the command line\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add -fastest to readme
61,745
31.10.2020 20:45:14
0
0379dc394cb0f627a3c0132ca1732b97cd7294dc
Add change log for 2.x series
[ { "change_type": "ADD", "old_path": null, "new_path": "Docs/ChangeLog.md", "diff": "+# 2.x series change log\n+\n+This page summarizes the major changes in each release of the 2.x series.\n+\n+## 2.1\n+\n+**Status:** :warning: In development (ETA November 2020)\n+\n+The 2.1 release is the second release in the 2.x series. It includes a number\n+of performance optimizations and new features.\n+### Features:\n+\n+* **Command line:**\n+ * **Bug fix:** The meaning of the `-tH\\cH\\dH` and `-th\\ch\\dh` compression\n+ modes was inverted. They now match the documentation; use `-*H` for HDR\n+ RGBA, and `-*h` for HDR RGB with LDR alpha.\n+ * **Feature:** A new `-fastest` quality preset is now available. This is\n+ designed for fast roughing out of new content, and sacrifices significant\n+ image quality compared to `-fast`.\n+ * **Feature:** A new `-candidatelimit` compression tuning option is now\n+ available. This is a power-user control to determine how many candidates\n+ are returned for each block mode encoding trial. This feature is used\n+ automatically by the search presets; see `-help` for details.\n+* **Core API:**\n+ * **Feature:** A new quality preset `ASTCENC_PRE_FASTEST` is available. See\n+ `-fastest` above for details.\n+ * **Feature:** A new tuning option `tune_candidate_limit` is available in\n+ the config structure. See `-candidatelimit` above for details.\n+ * **Feature:** Image input/output can now use `ASTCENC_TYPE_F32` data types.\n+* **Stability:**\n+ * **Improvement:** The SSE and AVX variants now produce identical output when\n+ run on the same CPU.\n+\n+### Performance\n+\n+* Average compression performance is 1.2x - 2x faster than version 2.0,\n+ depending on search preset and block size.\n+* Average image quality is similar to 2.0, with only minor differences of\n+ up to 0.05dB in either direction.\n+\n+## 2.0\n+\n+**Status:** Released, August 2020\n+\n+The 2.0 release is first release in the 2.x series. It includes a number of\n+major changes over the earlier 1.7 series, and is not command-line compatible.\n+\n+### Features:\n+\n+* The core codec can be built as a library, exposed via a new codec API.\n+* The core codec supports accelerated SIMD paths for SSE2, SSE4.2, and AVX2.\n+* The command line syntax has a clearer mapping to Khronos feature profiles.\n+\n+### Performance:\n+\n+* Average compression performance is between 2 and 3x faster than version 1.7.\n+* Average image quality is lower by up to 0.1dB than version 1.7.\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -62,7 +62,8 @@ Release build binaries for the `astcenc` stable releases are provided in the\n[GitHub Releases page](https://github.com/ARM-software/astc-encoder/releases).\nBinaries are provided for 64-bit builds on Windows, macOS, and Linux.\n-The latest stable release is version 2.0.\n+* Latest stable release: 2.0.\n+* Change log: [2.x series](./Docs/ChangeLog.md)\n## astcenc 2.x binaries\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add change log for 2.x series
61,745
31.10.2020 21:22:32
0
738c7015eaba6f4246c5352e88717868f630abef
Allow null output file in test mode In test mode, specifying "/dev/null" on Linux/macOS, or "NUL" or "nul" on Windows, will cause the write of the output file to be omitted. This can substantially improve test thoughput in cases where only the PSNR metrics are required.
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1206,6 +1206,14 @@ int main(\nint store_result = -1;\nconst char *format_string = \"\";\n+#if defined(_WIN32)\n+ bool is_null = output_filename == \"NUL\" || output_filename == \"nul\";\n+#else\n+ bool is_null = output_filename == \"/dev/null\";\n+#endif\n+\n+ if (!is_null)\n+ {\nstore_result = store_ncimage(image_decomp_out, output_filename.c_str(),\n&format_string, cli_config.y_flip);\nif (store_result < 0)\n@@ -1214,6 +1222,7 @@ int main(\nreturn 1;\n}\n}\n+ }\nfree_image(image_uncomp_in);\nfree_image(image_decomp_out);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Allow null output file in test mode In test mode, specifying "/dev/null" on Linux/macOS, or "NUL" or "nul" on Windows, will cause the write of the output file to be omitted. This can substantially improve test thoughput in cases where only the PSNR metrics are required.
61,745
31.10.2020 21:53:11
0
4f365a44c54545f69f72dbffb143b5c99af8307e
Change perf suite to discard images by deafult
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -182,7 +182,8 @@ def format_result(image, reference, result):\n(name, tPSNR, tTTime, tCTime, tCMPS, result.name)\n-def run_test_set(encoder, testRef, testSet, quality, blockSizes, testRuns):\n+def run_test_set(encoder, testRef, testSet, quality, blockSizes, testRuns,\n+ keepOutput):\n\"\"\"\nExecute all tests in the test set.\n@@ -193,6 +194,9 @@ def run_test_set(encoder, testRef, testSet, quality, blockSizes, testRuns):\nquality (str): The quality level to execute the test against.\nblockSizes (list(str)): The block sizes to execute each test against.\ntestRuns (int): The number of test repeats to run for each image test.\n+ keepOutput (bool): Should the test preserve output images? This is\n+ only a hint and discarding output may be ignored if the encoder\n+ version used can't do it natively.\nReturns:\nResultSet: The test results.\n@@ -217,7 +221,8 @@ def run_test_set(encoder, testRef, testSet, quality, blockSizes, testRuns):\ndat = (curCount, maxCount, blkSz, image.testFile)\nprint(\"Running %u/%u %s %s ... \" % dat, end='', flush=True)\n- res = encoder.run_test(image, blkSz, \"-%s\" % quality, testRuns)\n+ res = encoder.run_test(image, blkSz, \"-%s\" % quality, testRuns,\n+ keepOutput)\nres = trs.Record(blkSz, image.testFile, res[0], res[1], res[2])\nresultSet.add_record(res)\n@@ -358,6 +363,9 @@ def parse_command_line():\nparser.add_argument(\"--repeats\", dest=\"testRepeats\", default=1,\ntype=int, help=\"test iteration count\")\n+ parser.add_argument(\"--keep-output\", dest=\"keepOutput\", default=False,\n+ action=\"store_true\", help=\"keep image output\")\n+\nargs = parser.parse_args()\n# Turn things into canonical format lists\n@@ -420,7 +428,8 @@ def main():\nargs.profiles, args.formats, args.testImage)\nresultSet = run_test_set(encoder, testRef, testSet, quality,\n- args.blockSizes, args.testRepeats)\n+ args.blockSizes, args.testRepeats,\n+ args.keepOutput)\nresultSet.save_to_file(testRes)\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/encoder.py", "new_path": "Test/testlib/encoder.py", "diff": "@@ -60,7 +60,8 @@ class EncoderBase():\nself.variant = variant\nself.binary = binary\n- def build_cli(self, image, blockSize=\"6x6\", preset=\"-thorough\"):\n+ def build_cli(self, image, blockSize=\"6x6\", preset=\"-thorough\",\n+ keepOutput=True):\n\"\"\"\nBuild the command line needed for the given test.\n@@ -68,6 +69,9 @@ class EncoderBase():\nimage (TestImage): The test image to compress.\nblockSize (str): The block size to use.\npreset (str): The quality-performance preset to use.\n+ keepOutput (bool): Should the test preserve output images? This is\n+ only a hint and discarding output may be ignored if the encoder\n+ version used can't do it natively.\nReturns:\nlist(str): A list of command line arguments.\n@@ -175,7 +179,7 @@ class EncoderBase():\n# pylint: disable=unused-argument,no-self-use,redundant-returns-doc\nassert False, \"Missing subclass implementation\"\n- def run_test(self, image, blockSize, preset, testRuns):\n+ def run_test(self, image, blockSize, preset, testRuns, keepOutput=True):\n\"\"\"\nRun the test N times.\n@@ -184,6 +188,9 @@ class EncoderBase():\nblockSize (str): The block size to use.\npreset (str): The quality-performance preset to use.\ntestRuns (int): The number of test runs.\n+ keepOutput (bool): Should the test preserve output images? This is\n+ only a hint and discarding output may be ignored if the encoder\n+ version used can't do it natively.\nReturns:\ntuple(float, float, float): Returns the best results from the N\n@@ -191,7 +198,7 @@ class EncoderBase():\n(seconds).\n\"\"\"\n# pylint: disable=assignment-from-no-return\n- command = self.build_cli(image, blockSize, preset)\n+ command = self.build_cli(image, blockSize, preset, keepOutput)\n# Execute test runs\nbestPSNR = 0\n@@ -242,10 +249,12 @@ class Encoder2x(EncoderBase):\nsuper().__init__(name, variant, binary)\n- def build_cli(self, image, blockSize=\"6x6\", preset=\"-thorough\"):\n+ def build_cli(self, image, blockSize=\"6x6\", preset=\"-thorough\",\n+ keepOutput=True):\nopmode = self.SWITCHES[image.colorProfile]\nsrcPath = image.filePath\n+ if keepOutput:\ndstPath = image.outFilePath + self.OUTPUTS[image.colorProfile]\ndstDir = os.path.dirname(dstPath)\ndstFile = os.path.basename(dstPath)\n@@ -253,6 +262,10 @@ class Encoder2x(EncoderBase):\ndstDir = os.path.dirname(dstPath)\nos.makedirs(dstDir, exist_ok=True)\n+ elif sys.platform == \"win32\":\n+ dstPath = \"nul\"\n+ else:\n+ dstPath = \"/dev/null\"\ncommand = [\nself.binary, opmode, srcPath, dstPath,\n@@ -330,7 +343,8 @@ class Encoder1_7(EncoderBase):\nsuper().__init__(name, None, binary)\n- def build_cli(self, image, blockSize=\"6x6\", preset=\"-thorough\"):\n+ def build_cli(self, image, blockSize=\"6x6\", preset=\"-thorough\",\n+ keepOutput=True):\nopmode = self.SWITCHES[image.colorProfile]\nsrcPath = image.filePath\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/image.py", "new_path": "Test/testlib/image.py", "diff": "@@ -62,7 +62,7 @@ class TestImage():\nFORMATS: Tuple of valid color format values.\nFLAGS: Map of valid flags (key) and their meaning (value).\n\"\"\"\n- TEST_EXTS = (\".jpg\", \".png\", \".dds\", \".hdr\")\n+ TEST_EXTS = (\".jpg\", \".png\", \".tga\", \".dds\", \".hdr\")\nPROFILES = (\"ldr\", \"ldrs\", \"hdr\")\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/resultset.py", "new_path": "Test/testlib/resultset.py", "diff": "@@ -27,6 +27,7 @@ compared against a set of reference results created by an earlier test run.\nimport csv\nimport enum\nimport numpy as np\n+import os\n@enum.unique\n@@ -275,6 +276,10 @@ class ResultSet():\nArgs:\nfilePath (str): The output file path.\n\"\"\"\n+ dirName = os.path.dirname(filePath)\n+ if not os.path.exists(dirName):\n+ os.makedirs(dirName)\n+\nwith open(filePath, \"w\") as csvfile:\nwriter = csv.writer(csvfile)\nself._save_header(writer)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Change perf suite to discard images by deafult
61,745
01.11.2020 11:19:56
0
cca3648e060f793c6edc6451b19e364cb7f15888
Add MT/s rate to metrics report
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -332,35 +332,35 @@ void compute_error_metrics(\nfloat rgb_psnr = psnr;\n- printf(\"Error metrics\\n\");\n- printf(\"=============\\n\\n\");\n+ printf(\"Quality metrics\\n\");\n+ printf(\"===============\\n\\n\");\nif (channelmask & 8)\n{\n- printf(\" PSNR (LDR-RGBA): %9.6f dB\\n\", (double)psnr);\n+ printf(\" PSNR (LDR-RGBA): %9.4f dB\\n\", (double)psnr);\nfloat alpha_psnr;\nif (alpha_num == 0.0f)\nalpha_psnr = 999.0f;\nelse\nalpha_psnr = 10.0f * log10f(denom / alpha_num);\n- printf(\" Alpha-weighted PSNR: %9.6f dB\\n\", (double)alpha_psnr);\n+ printf(\" Alpha-weighted PSNR: %9.4f dB\\n\", (double)alpha_psnr);\nfloat rgb_num = errorsum.sum.x + errorsum.sum.y + errorsum.sum.z;\nif (rgb_num == 0.0f)\nrgb_psnr = 999.0f;\nelse\nrgb_psnr = 10.0f * log10f(pixels * 3.0f / rgb_num);\n- printf(\" PSNR (LDR-RGB): %9.6f dB\\n\", (double)rgb_psnr);\n+ printf(\" PSNR (LDR-RGB): %9.4f dB\\n\", (double)rgb_psnr);\n}\nelse\n{\n- printf(\" PSNR (LDR-RGB): %9.6f dB\\n\", (double)psnr);\n+ printf(\" PSNR (LDR-RGB): %9.4f dB\\n\", (double)psnr);\n}\nif (compute_hdr_metrics)\n{\n- printf(\" PSNR (RGB norm to peak): %9.6f dB (peak %f)\\n\",\n+ printf(\" PSNR (RGB norm to peak): %9.4f dB (peak %f)\\n\",\n(double)(rgb_psnr + 20.0f * log10f(rgb_peak)),\n(double)rgb_peak);\n@@ -369,11 +369,11 @@ void compute_error_metrics(\nmpsnr = 999.0f;\nelse\nmpsnr = 10.0f * log10f(mpsnr_denom / mpsnr_num);\n- printf(\" mPSNR (RGB): %9.6f dB (fstops %+d to %+d)\\n\",\n+ printf(\" mPSNR (RGB): %9.4f dB (fstops %+d to %+d)\\n\",\n(double)mpsnr, fstop_lo, fstop_hi);\nfloat logrmse = astc::sqrt(log_num / pixels);\n- printf(\" LogRMSE (RGB): %9.6f\\n\", (double)logrmse);\n+ printf(\" LogRMSE (RGB): %9.4f\\n\", (double)logrmse);\n}\nprintf(\"\\n\");\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1093,6 +1093,10 @@ int main(\ndouble start_coding_time = get_time();\n+ double image_size = (double)image_uncomp_in->dim_x *\n+ (double)image_uncomp_in->dim_y *\n+ (double)image_uncomp_in->dim_z;\n+\n// Compress an image\nif (operation & ASTCENC_STAGE_COMPRESS)\n{\n@@ -1196,6 +1200,7 @@ int main(\nelse\n{\nprintf(\"ERROR: Unknown compressed output file type\\n\");\n+\nreturn 1;\n}\n}\n@@ -1232,12 +1237,16 @@ int main(\ndouble end_time = get_time();\n+ double tex_rate = image_size / (end_coding_time - start_coding_time);\n+ tex_rate = tex_rate / 1000000.0;\n+\nif ((operation & ASTCENC_STAGE_COMPARE) || (!cli_config.silentmode))\n{\n- printf(\"Coding time\\n\");\n- printf(\"===========\\n\\n\");\n- printf(\" Total time: %6.4f s\\n\", end_time - start_time);\n- printf(\" Coding time: %6.4f s\\n\", end_coding_time - start_coding_time);\n+ printf(\"Performance metrics\\n\");\n+ printf(\"===================\\n\\n\");\n+ printf(\" Total time: %8.4f s\\n\", end_time - start_time);\n+ printf(\" Coding time: %8.4f s\\n\", end_coding_time - start_coding_time);\n+ printf(\" Coding rate: %8.4f MT/s\\n\", tex_rate);\n}\nreturn 0;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add MT/s rate to metrics report
61,745
01.11.2020 12:01:32
0
cbc24d1ec2d7acebb8e6e266aac562c93135db54
Add parser for MT/s data to archive Note rebuilding reference data for older encoders now needs a modified encoder which emits a version 2.1 performance metric field, so we get consistent data from all of them.
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -133,20 +133,14 @@ def format_solo_result(image, result):\nReturns:\nstr: The metrics string.\n\"\"\"\n- imSize = image.get_size()\n- if imSize:\n- mpix = float(imSize[0] * imSize[1]) / 1000000.0\n- tCMPS = \"%3.3f MP/s\" % (mpix / result.cTime)\n- else:\n- tCMPS = \"?\"\n-\nname = \"%5s %s\" % (result.blkSz, result.name)\ntPSNR = \"%2.3f dB\" % result.psnr\ntTTime = \"%.3f s\" % result.tTime\ntCTime = \"%.3f s\" % result.cTime\n+ tCMTS = \"%.3f MT/s\" % result.cRate\nreturn \"%-32s | %8s | %9s | %9s | %10s\" % \\\n- (name, tPSNR, tTTime, tCTime, tCMPS)\n+ (name, tPSNR, tTTime, tCTime, tCMTS)\ndef format_result(image, reference, result):\n@@ -161,13 +155,6 @@ def format_result(image, reference, result):\nReturns:\nstr: The metrics string.\n\"\"\"\n- imSize = image.get_size()\n- if imSize:\n- mpix = float(imSize[0] * imSize[1]) / 1000000.0\n- tCMPS = \"%3.3f MP/s\" % (mpix / result.cTime)\n- else:\n- tCMPS = \"?\"\n-\ndPSNR = result.psnr - reference.psnr\nsTTime = reference.tTime / result.tTime\nsCTime = reference.cTime / result.cTime\n@@ -176,10 +163,11 @@ def format_result(image, reference, result):\ntPSNR = \"%2.3f dB (% 1.3f dB)\" % (result.psnr, dPSNR)\ntTTime = \"%.3f s (%1.2fx)\" % (result.tTime, sTTime)\ntCTime = \"%.3f s (%1.2fx)\" % (result.cTime, sCTime)\n+ tCMTS = \"%.3f MT/s\" % (result.cRate)\nresult = determine_result(image, reference, result)\nreturn \"%-32s | %22s | %15s | %15s | %10s | %s\" % \\\n- (name, tPSNR, tTTime, tCTime, tCMPS, result.name)\n+ (name, tPSNR, tTTime, tCTime, tCMTS, result.name)\ndef run_test_set(encoder, testRef, testSet, quality, blockSizes, testRuns,\n@@ -223,7 +211,7 @@ def run_test_set(encoder, testRef, testSet, quality, blockSizes, testRuns,\nprint(\"Running %u/%u %s %s ... \" % dat, end='', flush=True)\nres = encoder.run_test(image, blkSz, \"-%s\" % quality, testRuns,\nkeepOutput)\n- res = trs.Record(blkSz, image.testFile, res[0], res[1], res[2])\n+ res = trs.Record(blkSz, image.testFile, res[0], res[1], res[2], res[3])\nresultSet.add_record(res)\nif testRef:\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/encoder.py", "new_path": "Test/testlib/encoder.py", "diff": "@@ -118,11 +118,13 @@ class EncoderBase():\npatternPSNR = re.compile(self.get_psnr_pattern(image))\npatternTTime = re.compile(self.get_total_time_pattern())\npatternCTime = re.compile(self.get_coding_time_pattern())\n+ patternCRate = re.compile(self.get_coding_rate_pattern())\n# Extract results from the log\nrunPSNR = None\nrunTTime = None\nrunCTime = None\n+ runCRate = None\nfor line in output:\nmatch = patternPSNR.match(line)\n@@ -137,11 +139,16 @@ class EncoderBase():\nif match:\nrunCTime = float(match.group(1))\n+ match = patternCRate.match(line)\n+ if match:\n+ runCRate = float(match.group(1))\n+\nstdout = \"\\n\".join(output)\nassert runPSNR is not None, \"No coding PSNR found %s\" % stdout\nassert runTTime is not None, \"No total time found %s\" % stdout\nassert runCTime is not None, \"No coding time found %s\" % stdout\n- return (runPSNR, runTTime, runCTime)\n+ assert runCRate is not None, \"No coding rate found %s\" % stdout\n+ return (runPSNR, runTTime, runCTime, runCRate)\ndef get_psnr_pattern(self, image):\n\"\"\"\n@@ -193,9 +200,9 @@ class EncoderBase():\nversion used can't do it natively.\nReturns:\n- tuple(float, float, float): Returns the best results from the N\n- test runs, as PSNR (dB), total time (seconds), and coding time\n- (seconds).\n+ tuple(float, float, float, float): Returns the best results from\n+ the N test runs, as PSNR (dB), total time (seconds), coding time\n+ (seconds), and coding rate (M pixels/s).\n\"\"\"\n# pylint: disable=assignment-from-no-return\ncommand = self.build_cli(image, blockSize, preset, keepOutput)\n@@ -204,17 +211,19 @@ class EncoderBase():\nbestPSNR = 0\nbestTTime = sys.float_info.max\nbestCTime = sys.float_info.max\n+ bestCRate = 0\nfor _ in range(0, testRuns):\noutput = self.execute(command)\nresult = self.parse_output(image, output)\n- # Keep the best results (highest PSNR, lowest times)\n+ # Keep the best results (highest PSNR, lowest times, highest rate)\nbestPSNR = max(bestPSNR, result[0])\nbestTTime = min(bestTTime, result[1])\nbestCTime = min(bestCTime, result[2])\n+ bestCRate = max(bestCRate, result[3])\n- return (bestPSNR, bestTTime, bestCTime)\n+ return (bestPSNR, bestTTime, bestCTime, bestCRate)\nclass Encoder2x(EncoderBase):\n@@ -300,6 +309,9 @@ class Encoder2x(EncoderBase):\ndef get_coding_time_pattern(self):\nreturn r\"\\s*Coding time:\\s*([0-9.]*) s\"\n+ def get_coding_rate_pattern(self):\n+ return r\"\\s*Coding rate:\\s*([0-9.]*) MT/s\"\n+\nclass Encoder2_0(Encoder2x):\n\"\"\"\n@@ -386,7 +398,15 @@ class Encoder1_7(EncoderBase):\nreturn patternPSNR\ndef get_total_time_pattern(self):\n- return r\"Elapsed time:\\s*([0-9.]*) seconds.*\"\n+ # Pattern match on a new pattern for a 2.1 compatible variant\n+ # return r\"Elapsed time:\\s*([0-9.]*) seconds.*\"\n+ return r\"\\s*Total time:\\s*([0-9.]*) s\"\ndef get_coding_time_pattern(self):\n- return r\".* coding time: \\s*([0-9.]*) seconds\"\n+ # Pattern match on a new pattern for a 2.1 compatible variant\n+ # return r\".* coding time: \\s*([0-9.]*) seconds\"\n+ return r\"\\s*Coding time:\\s*([0-9.]*) s\"\n+\n+ def get_coding_rate_pattern(self):\n+ # Pattern match on a new pattern for a 2.1 compatible variant\n+ return r\"\\s*Coding rate:\\s*([0-9.]*) MT/s\"\n" }, { "change_type": "MODIFY", "old_path": "Test/testlib/resultset.py", "new_path": "Test/testlib/resultset.py", "diff": "@@ -144,10 +144,11 @@ class Record():\npsnr: The image quality (PSNR dB)\ntTime: The total compression time.\ncTime: The coding compression time.\n+ cRate: The coding compression rate.\nstatus: The test Result.\n\"\"\"\n- def __init__(self, blkSz, name, psnr, tTime, cTime):\n+ def __init__(self, blkSz, name, psnr, tTime, cTime, cRate):\n\"\"\"\nCreate a result record, initially in the NOTRUN status.\n@@ -157,8 +158,10 @@ class Record():\npsnr (float): The image quality PSNR, in dB.\ntTime (float): The total compression time, in seconds.\ncTime (float): The coding compression time, in seconds.\n+ cRate (float): The coding compression rate, in MPix/s.\ntTimeRel (float): The relative total time speedup vs reference.\ncTimeRel (float): The relative coding time speedup vs reference.\n+ cRateRel (float): The relative rate speedup vs reference.\npsnrRel (float): The relative PSNR dB vs reference.\n\"\"\"\nself.blkSz = blkSz\n@@ -166,10 +169,12 @@ class Record():\nself.psnr = psnr\nself.tTime = tTime\nself.cTime = cTime\n+ self.cRate = cRate\nself.status = Result.NOTRUN\nself.tTimeRel = None\nself.cTimeRel = None\n+ self.cRateRel = None\nself.psnrRel = None\ndef set_status(self, result):\n@@ -295,7 +300,7 @@ class ResultSet():\nwriter (csv.writer): The CSV writer.\n\"\"\"\nrow = [\"Image Set\", \"Block Size\", \"Name\",\n- \"PSNR\", \"Total Time\", \"Coding Time\"]\n+ \"PSNR\", \"Total Time\", \"Coding Time\", \"Coding Rate\"]\nwriter.writerow(row)\ndef _save_record(self, writer, record):\n@@ -309,9 +314,10 @@ class ResultSet():\nrow = [self.testSet,\nrecord.blkSz,\nrecord.name,\n- \"%0.5f\" % record.psnr,\n+ \"%0.4f\" % record.psnr,\n\"%0.4f\" % record.tTime,\n- \"%0.4f\" % record.cTime]\n+ \"%0.4f\" % record.cTime,\n+ \"%0.4f\" % record.cRate]\nwriter.writerow(row)\ndef load_from_file(self, filePath):\n@@ -328,5 +334,6 @@ class ResultSet():\nfor row in reader:\nassert row[0] == self.testSet\nrecord = Record(row[1], row[2],\n- float(row[3]), float(row[4]), float(row[5]))\n+ float(row[3]), float(row[4]),\n+ float(row[5]), float(row[6]))\nself.add_record(record)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add parser for MT/s data to archive Note rebuilding reference data for older encoders now needs a modified encoder which emits a version 2.1 performance metric field, so we get consistent data from all of them.
61,745
01.11.2020 12:44:27
0
e543a8cf9fa1e72b573d7a65a5309e55de599e52
Add more entries to 2.1 change log
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -22,6 +22,8 @@ of performance optimizations and new features.\navailable. This is a power-user control to determine how many candidates\nare returned for each block mode encoding trial. This feature is used\nautomatically by the search presets; see `-help` for details.\n+ * **Improvement:** The compression test modes (`-tl\\ts\\th\\tH`) now emit a\n+ MTex/s performance metric, in addition to coding time.\n* **Core API:**\n* **Feature:** A new quality preset `ASTCENC_PRE_FASTEST` is available. See\n`-fastest` above for details.\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add more entries to 2.1 change log
61,745
01.11.2020 12:47:07
0
7c597c20c005dfc8fd4cdacb25a89b49e63d6aaa
Set version number to 2.1
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nconst char *astcenc_copyright_string =\n-R\"(ASTC codec v2.0.alpha, %u-bit %s%s\n+R\"(ASTC codec v2.1, %u-bit %s%s\nCopyright 2011-2020 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Set version number to 2.1
61,745
01.11.2020 12:57:17
0
aaf7dd3d8145d69b7b7c67179df52c18c3b8a4f9
Add note on recompiles to ChangeLog
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -8,6 +8,11 @@ This page summarizes the major changes in each release of the 2.x series.\nThe 2.1 release is the second release in the 2.x series. It includes a number\nof performance optimizations and new features.\n+\n+Reminder for users of the library interface - the API is not designed to be\n+stable across versions, and this release is not compatible with 2.0. Please\n+recompile the client-side using the updated `astcenc.h` header.\n+\n### Features:\n* **Command line:**\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add note on recompiles to ChangeLog
61,745
03.11.2020 22:03:39
0
1eec122701e8f4d9a23e472bf8f9693595bd8929
Add invariant build option.
[ { "change_type": "MODIFY", "old_path": "Docs/Building.md", "new_path": "Docs/Building.md", "diff": "@@ -80,3 +80,9 @@ non-optimized build (`-O0`) with symbols included (`-g`).\nFor easier profiling, add `BUILD=profile` to the Make command line. This will\nbuild a moderately optimized build (`-O2`) with symbols include (`-g`), but\nwithout link-time optimization (no `-flto`).\n+\n+Normal builds are not ISA invariant, builds for different instruction sets on\n+the same CPU hardware can produce subtly different outputs. To build an ISA\n+invariant build set `-DASTCENC_ISA_INVARIANCE=1`. For make builds this can be\n+achieved by setting `ISA_INV=1` on the command line. This will reduce\n+performance, as optimizations will be disabled to keep alignment with SSE2.\n" }, { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "# 2.x series change log\n-This page summarizes the major changes in each release of the 2.x series.\n+This page summarizes the major functional and performance changes in each\n+release of the 2.x series.\n## 2.1\n@@ -36,15 +37,26 @@ recompile the client-side using the updated `astcenc.h` header.\nthe config structure. See `-candidatelimit` above for details.\n* **Feature:** Image input/output can now use `ASTCENC_TYPE_F32` data types.\n* **Stability:**\n- * **Improvement:** The SSE and AVX variants now produce identical output when\n- run on the same CPU.\n+ * **Feature:** The SSE2, SSE4.2, and AVX2 variants now produce identical\n+ compressed output when run on the same CPU when compiled with the option\n+ `ASTCENC_ISA_INVARIANCE=1`. For Make builds this can be set on the command\n+ line by setting `ISA_INV=1`. ISA invariance is off by default; it reduces\n+ performance by 1-3%.\n### Performance\n-* Average compression performance is 1.2x - 2x faster than version 2.0,\n- depending on search preset and block size.\n-* Average image quality is similar to 2.0, with only minor differences of\n- up to 0.05dB in either direction.\n+Key for performance charts\n+\n+* Color = block size (see legend).\n+* Letter = image format (N = normal map, G = greyscale, L = LDR, H = HDR).\n+\n+**Absolute performance:**\n+\n+![Absolute scores 2.1 vs 2.0](./ChangeLogImg/absolute-2.0-to-2.1.png)\n+\n+**Relative performance vs 1.7 release:**\n+\n+![Relative scores 2.1 vs 2.0](./ChangeLogImg/relative-2.0-to-2.1.png)\n## 2.0\n@@ -61,5 +73,15 @@ major changes over the earlier 1.7 series, and is not command-line compatible.\n### Performance:\n-* Average compression performance is between 2 and 3x faster than version 1.7.\n-* Average image quality is lower by up to 0.1dB than version 1.7.\n+Key for performance charts\n+\n+* Color = block size (see legend).\n+* Letter = image format (N = normal map, G = greyscale, L = LDR, H = HDR).\n+\n+**Absolute performance:**\n+\n+![Absolute scores 2.0 vs 1.7](./ChangeLogImg/absolute-1.7-to-2.0.png)\n+\n+**Relative performance vs 1.7 release:**\n+\n+![Relative scores 2.0 vs 1.7](./ChangeLogImg/relative-1.7-to-2.0.png)\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/absolute-1.7-to-2.0.png", "new_path": "Docs/ChangeLogImg/absolute-1.7-to-2.0.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/absolute-1.7-to-2.0.png differ\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/absolute-2.0-to-2.1.png", "new_path": "Docs/ChangeLogImg/absolute-2.0-to-2.1.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/absolute-2.0-to-2.1.png differ\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/relative-1.7-to-2.0.png", "new_path": "Docs/ChangeLogImg/relative-1.7-to-2.0.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/relative-1.7-to-2.0.png differ\n" }, { "change_type": "ADD", "old_path": "Docs/ChangeLogImg/relative-2.0-to-2.1.png", "new_path": "Docs/ChangeLogImg/relative-2.0-to-2.1.png", "diff": "Binary files /dev/null and b/Docs/ChangeLogImg/relative-2.0-to-2.1.png differ\n" }, { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -41,6 +41,17 @@ VEC ?= avx2\n# * debug - build an unoptimized build with symbols\nBUILD ?= release\n+# Configure the build for ISA invariant output; valid values are:\n+#\n+# * 0 - ISA invariance is off (default)\n+# * 1 - ISA invariance is on\n+#\n+# Enabling ISA invariant output will give bit-exact compression across SSE2,\n+# SSE4.2, and AVX2. Thi will disable some optimizations for newer ISAs which\n+# cannot be reasonably implemented by the older ones, and will therefore reduce\n+# performance.\n+ISA_INV ?= 0\n+\n# ==================================================\n# File listings\n@@ -151,6 +162,17 @@ endif\nendif\nendif\n+# Validate that the ISA_ENV option is a valid option\n+ifeq ($(ISA_INV),0)\n+CXXFLAGS += -DASTCENC_ISA_INVARIANCE=0\n+else\n+ifeq ($(ISA_INV),1)\n+CXXFLAGS += -DASTCENC_ISA_INVARIANCE=1\n+else\n+$(error Unsupported ISA invariance, use ISA_INV=0/1)\n+endif\n+endif\n+\n# Disable necessary optimizations and warnings for third-party source files\nCXXFLAGS_EXTERNAL = \\\n$(CXXFLAGS) \\\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-avx2.vcxproj", "new_path": "Source/VS2019/astcenc-avx2.vcxproj", "diff": "<ClCompile>\n<Optimization>Disabled</Optimization>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;ASTCENC_ISA_INVARIANCE=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=32;ASTCENC_SSE=42;ASTCENC_AVX=2;ASTCENC_POPCNT=1;ASTCENC_ISA_INVARIANCE=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse2.vcxproj", "new_path": "Source/VS2019/astcenc-sse2.vcxproj", "diff": "<ClCompile>\n<Optimization>Disabled</Optimization>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;ASTCENC_ISA_INVARIANCE=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=20;ASTCENC_AVX=0;ASTCENC_POPCNT=0;ASTCENC_ISA_INVARIANCE=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n" }, { "change_type": "MODIFY", "old_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "new_path": "Source/VS2019/astcenc-sse4.2.vcxproj", "diff": "<ClCompile>\n<Optimization>Disabled</Optimization>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;ASTCENC_ISA_INVARIANCE=0;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n<ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n<ClCompile>\n<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n- <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n+ <PreprocessorDefinitions>WIN32;ASTCENC_VECALIGN=16;ASTCENC_SSE=42;ASTCENC_AVX=0;ASTCENC_POPCNT=1;ASTCENC_ISA_INVARIANCE=0;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n<RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n<BufferSecurityCheck>false</BufferSecurityCheck>\n<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_internal.h", "new_path": "Source/astcenc_internal.h", "diff": "#error ERROR: ASTCENC_AVX not defined\n#endif\n+#ifndef ASTCENC_ISA_INVARIANCE\n+#error ERROR: ASTCENC_ISA_INVARIANCE not defined\n+#endif\n+\n#include \"astcenc.h\"\n#include \"astcenc_mathlib.h\"\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "@@ -410,7 +410,7 @@ static inline uint4 operator*(uint32_t p, uint4 q) { return q * p; }\nstatic inline float dot(float2 p, float2 q) { return p.x * q.x + p.y * q.y; }\nstatic inline float dot(float3 p, float3 q) { return p.x * q.x + p.y * q.y + p.z * q.z; }\nstatic inline float dot(float4 p, float4 q) {\n-#if ASTCENC_SSE >= 42\n+#if (ASTCENC_SSE >= 42) && (ASTCENC_ISA_INVARIANCE == 0)\n__m128 pv = _mm_load_ps((float*)&p);\n__m128 qv = _mm_load_ps((float*)&q);\n__m128 t = _mm_dp_ps(pv, qv, 0xFF);\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_result_plot.py", "new_path": "Test/astc_test_result_plot.py", "diff": "@@ -74,6 +74,7 @@ def get_series(results, tgtEncoder, tgtQuality, resFilter=lambda x: True):\npsnrData = []\nmtsData = []\nmarker = []\n+ records = []\nfor imageSet, iResults in results.items():\n@@ -87,6 +88,7 @@ def get_series(results, tgtEncoder, tgtQuality, resFilter=lambda x: True):\nfor record in eResults.records:\nif resFilter(record):\n+ records.append(record)\npsnrData.append(record.psnr)\nmtsData.append(record.cRate)\n@@ -102,12 +104,12 @@ def get_series(results, tgtEncoder, tgtQuality, resFilter=lambda x: True):\nmarker.append('$?$')\n- return mtsData, psnrData, marker\n+ return mtsData, psnrData, marker, records\ndef get_series_rel(results, refEncoder, refQuality, tgtEncoder, tgtQuality, resFilter=lambda x: True):\n- mts1, psnr1, marker1 = get_series(results, tgtEncoder, tgtQuality, resFilter)\n+ mts1, psnr1, marker1, rec1 = get_series(results, tgtEncoder, tgtQuality, resFilter)\nif refEncoder is None:\nrefEncoder = tgtEncoder\n@@ -115,12 +117,12 @@ def get_series_rel(results, refEncoder, refQuality, tgtEncoder, tgtQuality, resF\nif refQuality is None:\nrefQuality = tgtQuality\n- mts2, psnr2, marker2 = get_series(results, refEncoder, refQuality, resFilter)\n+ mts2, psnr2, marker2, rec2 = get_series(results, refEncoder, refQuality, resFilter)\nmtsm = [x/mts2[i] for i, x in enumerate(mts1)]\npsnrm = [x - psnr2[i] for i, x in enumerate(psnr1)]\n- return mtsm, psnrm, marker1\n+ return mtsm, psnrm, marker1, rec1\ndef get_human_eq_name(encoder, quality):\n@@ -161,6 +163,9 @@ def plot(results, chartRows, chartCols, blockSizes,\nfor i, row in enumerate(chartRows):\nfor j, col in enumerate(chartCols):\nif row == \"fastest\" and \"ref-2.1\" not in col:\n+ if len(chartCols) == 1:\n+ fig.delaxes(axs[i])\n+ else:\nfig.delaxes(axs[i][j])\ncontinue\n@@ -192,9 +197,9 @@ def plot(results, chartRows, chartCols, blockSizes,\nfn = lambda x: x.blkSz == series\nif not relative:\n- x, y, m = get_series(results, col, row, fn)\n+ x, y, m, r = get_series(results, col, row, fn)\nelse:\n- x, y, m = get_series_rel(results, pivotEncoder, pivotQuality,\n+ x, y, m, r = get_series_rel(results, pivotEncoder, pivotQuality,\ncol, row, fn)\ncolor = None\n@@ -236,54 +241,76 @@ def main():\ncharts = [\n[\n- # Plot absolute scores\n+ # --------------------------------------------------------\n+ # Plot all absolute scores\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.0-avx2\", \"ref-2.1-avx2\"],\n+ [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ False,\n+ None,\n+ None,\n+ \"absolute-all.png\",\n+ (30, None)\n+ ], [\n+ # Plot 1.7 to 2.0 absolute scores\n[\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-1.7\", \"ref-2.0-avx2\", \"ref-2.1-avx2\"],\n+ [\"ref-1.7\", \"ref-2.0-avx2\"],\n[\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\nFalse,\nNone,\nNone,\n- \"absolute-vs-ref-1.7.png\",\n+ \"absolute-1.7-to-2.0.png\",\n(30, None)\n], [\n- # Plot relative scores of all vs 1.7\n+ # Plot 2.0 to 2.1 absolute scores\n+ [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n+ [\"ref-2.0-avx2\", \"ref-2.1-avx2\"],\n+ [\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\n+ False,\n+ None,\n+ None,\n+ \"absolute-2.0-to-2.1.png\",\n+ (30, None)\n+ ], [\n+ # --------------------------------------------------------\n+ # Plot all relative scores\n[\"thorough\", \"medium\", \"fast\"],\n[\"ref-2.0-avx2\", \"ref-2.1-avx2\"],\n[\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\nTrue,\n\"ref-1.7\",\nNone,\n- \"relative-vs-ref-1.7.png\",\n+ \"relative-all.png\",\n(None, None)\n], [\n- # Plot relative scores of all vs 2.0\n+ # Plot 1.7 to 2.0 relative scores\n[\"thorough\", \"medium\", \"fast\"],\n- [\"ref-2.1-avx2\"],\n+ [\"ref-2.0-avx2\"],\n[\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\nTrue,\n- \"ref-2.0-avx2\",\n+ \"ref-1.7\",\nNone,\n- \"relative-vs-ref-2.0.png\",\n+ \"relative-1.7-to-2.0.png\",\n(None, None)\n], [\n- # Plot relative scores of ISAs of latest\n- [\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.1-sse4.2\", \"ref-2.1-avx2\"],\n+ # Plot 2.0 to 2.1 relative scores\n+ [\"thorough\", \"medium\", \"fast\"],\n+ [\"ref-2.1-avx2\"],\n[\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\nTrue,\n- \"ref-2.1-sse2\",\n+ \"ref-2.0-avx2\",\nNone,\n- \"relative-vs-self-isa.png\",\n+ \"relative-2.0-to-2.1.png\",\n(None, None)\n], [\n# Plot relative scores of ISAs of latest\n[\"thorough\", \"medium\", \"fast\", \"fastest\"],\n- [\"ref-2.1-avx2\"],\n+ [\"ref-2.1-sse4.2\", \"ref-2.1-avx2\"],\n[\"4x4\", \"5x5\", \"6x6\", \"8x8\"],\nTrue,\n- \"ref-2.1-sse4.2\",\n+ \"ref-2.1-sse2\",\nNone,\n- \"relative-vs-self-isa-sse4.2.png\",\n+ \"relative-2.1-isas.png\",\n(None, None)\n], [\n# Plot relative scores of qualities of latest\n@@ -293,7 +320,7 @@ def main():\nTrue,\nNone,\n\"thorough\",\n- \"relative-vs-self-quality.png\",\n+ \"relative-2.1-qualities.png\",\n(None, None)\n]\n]\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add invariant build option.
61,745
03.11.2020 22:24:02
0
926611178b82746339052dba349f3768722dbd2d
Set default reference to 2.1
[ { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -333,7 +333,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.0-avx2\",\n+ parser.add_argument(\"--reference\", dest=\"reference\", default=\"ref-2.1-avx2\",\nchoices=refcoders, help=\"reference encoder variant\")\nastcProfile = [\"ldr\", \"ldrs\", \"hdr\", \"all\"]\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Set default reference to 2.1
61,745
05.11.2020 10:27:11
0
19aab9c198766fbf07d422e8a9445b232b51dcaa
Fix fuzz test builds
[ { "change_type": "MODIFY", "old_path": "Source/Fuzzers/build.sh", "new_path": "Source/Fuzzers/build.sh", "diff": "@@ -27,7 +27,11 @@ ar -qc libastcenc.a *.o\n# Build project local fuzzers\nfor fuzzer in $SRC/astc-encoder/Source/Fuzzers/fuzz_*.cpp; do\n$CXX $CXXFLAGS \\\n- -DASTCENC_SSE=0 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0 -DASTCENC_VECALIGN=16 \\\n+ -DASTCENC_SSE=0 \\\n+ -DASTCENC_AVX=0 \\\n+ -DASTCENC_POPCNT=0 \\\n+ -DASTCENC_VECALIGN=16 \\\n+ -DASTCENC_ISA_INVARIANCE=0 \\\n-I. -std=c++14 $fuzzer $LIB_FUZZING_ENGINE $SRC/astc-encoder/Source/libastcenc.a \\\n-o $OUT/$(basename -s .cpp $fuzzer)\ndone\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Fix fuzz test builds
61,745
05.11.2020 23:54:20
0
88d21e621dd19827830380159a13865e8eccc24e
Add callgrind_analyze to helper script
[ { "change_type": "MODIFY", "old_path": "Test/astc_profile_valgrind.py", "new_path": "Test/astc_profile_valgrind.py", "diff": "@@ -29,9 +29,67 @@ Only runs on Linux and requires the following tools available on the PATH:\nimport argparse\nimport os\n+import re\nimport subprocess as sp\nimport sys\n+def postprocess_cga(logfile, outfile):\n+ \"\"\"\n+ Postprocess the output of callgrind_annotate.\n+\n+ Args:\n+ logfile (str): The output of callgrind_annotate.\n+ outfile (str): The output file path to write.\n+ \"\"\"\n+ pattern = re.compile(\"^\\s*([0-9,]+)\\s+Source/(\\S+):(\\S+)\\(.*\\).*$\")\n+\n+ lines = logfile.splitlines()\n+\n+ totalCost = 0.0\n+ functionTable = []\n+ functionMap = {}\n+\n+ for line in lines:\n+ match = pattern.match(line)\n+ if not match:\n+ continue\n+\n+ cost = float(match.group(1).replace(\",\", \"\"))\n+ sourceFile = match.group(2)\n+ function = match.group(3)\n+\n+ # Filter out library code we don't want to change\n+ if function.startswith(\"stbi__\"):\n+ continue\n+\n+ totalCost += cost\n+\n+ # Accumulate the scores from functions in multiple call chains\n+ if function in functionMap:\n+ index = functionMap[function]\n+ functionTable[index][1] += cost\n+ functionTable[index][2] += cost\n+ # Else add new functions to the end of the table\n+ else:\n+ functionMap[function] = len(functionTable)\n+ functionTable.append([function, cost, cost])\n+\n+ # Sort the table by accumulated cost\n+ functionTable.sort(key=lambda x: 101.0 - x[2])\n+\n+ for function in functionTable:\n+ function[2] /= totalCost\n+ function[2] *= 100.0\n+\n+ with open(outfile, \"w\") as fileHandle:\n+ for function in functionTable:\n+ # Omit entries less than 1% load\n+ if function[2] < 1:\n+ break\n+\n+ fileHandle.write(\"%5.2f%% %s\\n\" % (function[2], function[0]))\n+\n+\ndef run_pass(image, encoder, blocksize, quality):\n\"\"\"\nRun Valgrind on a single binary.\n@@ -50,21 +108,25 @@ def run_pass(image, encoder, blocksize, quality):\nargs = [\"valgrind\", \"--tool=callgrind\", \"--callgrind-out-file=callgrind.txt\",\nbinary, \"-cl\", image, \"out.astc\", blocksize, qualityFlag, \"-j\", \"1\"]\n- print(\" \".join(args))\nresult = sp.run(args, check=True, universal_newlines=True)\n+ args = [\"callgrind_annotate\", \"callgrind.txt\"]\n+ ret = sp.run(args, stdout=sp.PIPE, check=True, encoding=\"utf-8\")\n+ postprocess_cga(ret.stdout, \"perf_%s.txt\" % quality)\n+\nargs = [\"gprof2dot\", \"--format=callgrind\", \"--output=out.dot\", \"callgrind.txt\",\n\"-s\", \"-z\", \"compress_block(astcenc_context const&, astcenc_image const&, imageblock const*, symbolic_compressed_block&, physical_compressed_block&, compress_symbolic_block_buffers*)\"]\nresult = sp.run(args, check=True, universal_newlines=True)\n- args = [\"dot\", \"-Tpng\", \"out.dot\", \"-o\", \"%s.png\" % quality]\n+ args = [\"dot\", \"-Tpng\", \"out.dot\", \"-o\", \"perf_%s.png\" % quality]\nresult = sp.run(args, check=True, universal_newlines=True)\nos.remove(\"out.astc\")\nos.remove(\"out.dot\")\nos.remove(\"callgrind.txt\")\n+\ndef parse_command_line():\n\"\"\"\nParse the command line.\n@@ -82,7 +144,7 @@ def parse_command_line():\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=encoders, help=\"select encoder variant\")\n- testqualities = [\"fast\", \"medium\", \"thorough\"]\n+ testqualities = [\"fastest\", \"fast\", \"medium\", \"thorough\"]\nqualities = testqualities + [\"all\"]\nparser.add_argument(\"--test-quality\", dest=\"qualities\", default=\"medium\",\nchoices=qualities, help=\"select compression quality\")\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add callgrind_analyze to helper script
61,745
08.11.2020 21:09:00
0
c5eec302622f1269412dadbf51b1c856f0e81050
Allow "nul" output for compressed images
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1199,11 +1199,18 @@ int main(\n}\nelse\n{\n+#if defined(_WIN32)\n+ bool is_null = output_filename == \"NUL\" || output_filename == \"nul\";\n+#else\n+ bool is_null = output_filename == \"/dev/null\";\n+#endif\n+ if (!is_null)\n+ {\nprintf(\"ERROR: Unknown compressed output file type\\n\");\n-\nreturn 1;\n}\n}\n+ }\n// Store decompressed image\nif (operation & ASTCENC_STAGE_ST_NCOMP)\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Allow "nul" output for compressed images
61,745
08.11.2020 21:09:29
0
d9a152ec1e5a437411856e18c286d8a7f69f5766
Report MT/s metrics for compress/decompress
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel.cpp", "new_path": "Source/astcenccli_toplevel.cpp", "diff": "@@ -1093,9 +1093,19 @@ int main(\ndouble start_coding_time = get_time();\n- double image_size = (double)image_uncomp_in->dim_x *\n+ double image_size = 0.0;\n+ if (image_uncomp_in)\n+ {\n+ image_size = (double)image_uncomp_in->dim_x *\n(double)image_uncomp_in->dim_y *\n(double)image_uncomp_in->dim_z;\n+ }\n+ else\n+ {\n+ image_size = (double)image_comp.dim_x *\n+ (double)image_comp.dim_y *\n+ (double)image_comp.dim_z;\n+ }\n// Compress an image\nif (operation & ASTCENC_STAGE_COMPRESS)\n@@ -1242,13 +1252,12 @@ int main(\ndelete[] image_comp.data;\n+ if ((operation & ASTCENC_STAGE_COMPARE) || (!cli_config.silentmode))\n+ {\ndouble end_time = get_time();\n-\ndouble tex_rate = image_size / (end_coding_time - start_coding_time);\ntex_rate = tex_rate / 1000000.0;\n- if ((operation & ASTCENC_STAGE_COMPARE) || (!cli_config.silentmode))\n- {\nprintf(\"Performance metrics\\n\");\nprintf(\"===================\\n\\n\");\nprintf(\" Total time: %8.4f s\\n\", end_time - start_time);\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Report MT/s metrics for compress/decompress
61,745
09.11.2020 00:18:37
0
375c3e8a16685bdb0d005d5f8deabd870c14d242
Use new scalar initializer for template vectors
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_averages_and_directions.cpp", "new_path": "Source/astcenc_averages_and_directions.cpp", "diff": "@@ -51,7 +51,7 @@ void compute_averages_and_directions_rgba(\nconst uint8_t *weights = pt->texels_of_partition[partition];\nint texelcount = pt->texels_per_partition[partition];\n- float4 base_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 base_sum = float4(0.0f);\nfloat partition_weight = 0.0f;\nfor (int i = 0; i < texelcount; i++)\n@@ -70,10 +70,10 @@ void compute_averages_and_directions_rgba(\nfloat4 average = base_sum * (1.0f / MAX(partition_weight, 1e-7f));\naverages[partition] = average * color_scalefactors[partition];\n- float4 sum_xp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 sum_yp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 sum_zp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 sum_wp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 sum_xp = float4(0.0f);\n+ float4 sum_yp = float4(0.0f);\n+ float4 sum_zp = float4(0.0f);\n+ float4 sum_wp = float4(0.0f);\nfor (int i = 0; i < texelcount; i++)\n{\n@@ -170,9 +170,9 @@ void compute_averages_and_directions_rgb(\nfloat3 average = base_sum * (1.0f / MAX(partition_weight, 1e-7f));\naverages[partition] = average * float3(csf.r, csf.g, csf.b);\n- float3 sum_xp = float3(0.0f, 0.0f, 0.0f);\n- float3 sum_yp = float3(0.0f, 0.0f, 0.0f);\n- float3 sum_zp = float3(0.0f, 0.0f, 0.0f);\n+ float3 sum_xp = float3(0.0f);\n+ float3 sum_yp = float3(0.0f);\n+ float3 sum_zp = float3(0.0f);\nfor (int i = 0; i < texelcount; i++)\n{\n@@ -271,7 +271,7 @@ void compute_averages_and_directions_3_components(\nconst uint8_t *weights = pt->texels_of_partition[partition];\nint texelcount = pt->texels_per_partition[partition];\n- float3 base_sum = float3(0.0f, 0.0f, 0.0f);\n+ float3 base_sum = float3(0.0f);\nfloat partition_weight = 0.0f;\nfor (int i = 0; i < texelcount; i++)\n@@ -291,9 +291,9 @@ void compute_averages_and_directions_3_components(\nfloat3 average = base_sum * (1.0f / MAX(partition_weight, 1e-7f));\naverages[partition] = average * float3(csf.r, csf.g, csf.b);\n- float3 sum_xp = float3(0.0f, 0.0f, 0.0f);\n- float3 sum_yp = float3(0.0f, 0.0f, 0.0f);\n- float3 sum_zp = float3(0.0f, 0.0f, 0.0f);\n+ float3 sum_xp = float3(0.0f);\n+ float3 sum_yp = float3(0.0f);\n+ float3 sum_zp = float3(0.0f);\nfor (int i = 0; i < texelcount; i++)\n{\n@@ -388,7 +388,7 @@ void compute_averages_and_directions_2_components(\nconst uint8_t *weights = pt->texels_of_partition[partition];\nint texelcount = pt->texels_per_partition[partition];\n- float2 base_sum = float2(0.0f, 0.0f);\n+ float2 base_sum = float2(0.0f);\nfloat partition_weight = 0.0f;\nfor (int i = 0; i < texelcount; i++)\n@@ -406,8 +406,8 @@ void compute_averages_and_directions_2_components(\nfloat2 average = base_sum * (1.0f / MAX(partition_weight, 1e-7f));\naverages[partition] = average * float2(csf.r, csf.g);\n- float2 sum_xp = float2(0.0f, 0.0f);\n- float2 sum_yp = float2(0.0f, 0.0f);\n+ float2 sum_xp = float2(0.0f);\n+ float2 sum_yp = float2(0.0f);\nfor (int i = 0; i < texelcount; i++)\n{\n@@ -479,8 +479,8 @@ void compute_error_squared_rgba(\nfloat samechroma_lowparam = 1e10f;\nfloat samechroma_highparam = -1e10f;\n- float4 separate_lowparam = float4(1e10f, 1e10f, 1e10f, 1e10f);\n- float4 separate_highparam = float4(-1e10f, -1e10f, -1e10f, -1e10f);\n+ float4 separate_lowparam = float4(1e10f);\n+ float4 separate_highparam = float4(-1e10f);\nprocessed_line4 l_uncorr = plines_uncorr[partition];\nprocessed_line4 l_samechroma = plines_samechroma[partition];\n@@ -633,8 +633,8 @@ void compute_error_squared_rgb(\nfloat samechroma_lowparam = 1e10f;\nfloat samechroma_highparam = -1e10f;\n- float3 separate_lowparam = float3(1e10f, 1e10f, 1e10f);\n- float3 separate_highparam = float3(-1e10f, -1e10f, -1e10f);\n+ float3 separate_lowparam = float3(1e10f);\n+ float3 separate_highparam = float3(-1e10f);\nprocessed_line3 l_uncorr = plines_uncorr[partition];\nprocessed_line3 l_samechroma = plines_samechroma[partition];\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -257,7 +257,7 @@ static void compress_symbolic_block_fixed_partition_1_plane(\n// compute maximum colors for the endpoints and ideal weights.\n// for each endpoint-and-ideal-weight pair, compute the smallest weight value\n// that will result in a color value greater than 1.\n- float4 min_ep = float4(10, 10, 10, 10);\n+ float4 min_ep = float4(10.0f);\nfor (int i = 0; i < partition_count; i++)\n{\n#ifdef DEBUG_CAPTURE_NAN\n@@ -525,8 +525,8 @@ static void compress_symbolic_block_fixed_partition_2_planes(\n// for each endpoint-and-ideal-weight pair, compute the smallest weight value\n// that will result in a color value greater than 1.\n- float4 min_ep1 = float4(10, 10, 10, 10);\n- float4 min_ep2 = float4(10, 10, 10, 10);\n+ float4 min_ep1 = float4(10.0f);\n+ float4 min_ep2 = float4(10.0f);\nfor (int i = 0; i < partition_count; i++)\n{\n#ifdef DEBUG_CAPTURE_NAN\n@@ -887,7 +887,7 @@ static float prepare_error_weight_block(\nif (xpos >= input_image.dim_x || ypos >= input_image.dim_y || zpos >= input_image.dim_z)\n{\n- float4 weights = float4(1e-11f, 1e-11f, 1e-11f, 1e-11f);\n+ float4 weights = float4(1e-11f);\newb->error_weights[idx] = weights;\newb->contains_zeroweight_texels = 1;\n}\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_compute_variance.cpp", "new_path": "Source/astcenc_compute_variance.cpp", "diff": "@@ -312,7 +312,7 @@ static void compute_pixel_region_variance(\n}\n// Pad with an extra layer of 0s; this forms the edge of the SAT tables\n- float4 vbz = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 vbz = float4(0.0f);\nfor (int z = 0; z < padsize_z; z++)\n{\nfor (int y = 0; y < padsize_y; y++)\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_encoding_choice_error.cpp", "new_path": "Source/astcenc_encoding_choice_error.cpp", "diff": "@@ -148,7 +148,7 @@ void compute_encoding_choice_errors(\nuncorr_rgb_lines[i].b = normalize(directions_rgb[i]);\n}\n- samechroma_rgb_lines[i].a = float3(0.0f, 0.0f, 0.0f);\n+ samechroma_rgb_lines[i].a = float3(0.0f);\nif (dot(averages[i], averages[i]) < 1e-20f)\n{\nsamechroma_rgb_lines[i].b = normalize(csf);\n@@ -161,7 +161,7 @@ void compute_encoding_choice_errors(\nrgb_luma_lines[i].a = averages[i];\nrgb_luma_lines[i].b = normalize(csf);\n- luminance_lines[i].a = float3(0.0f, 0.0f, 0.0f);\n+ luminance_lines[i].a = float3(0.0f);\nluminance_lines[i].b = normalize(csf);\nproc_uncorr_rgb_lines[i].amod = (uncorr_rgb_lines[i].a - uncorr_rgb_lines[i].b * dot(uncorr_rgb_lines[i].a, uncorr_rgb_lines[i].b)) * icsf;\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_find_best_partitioning.cpp", "new_path": "Source/astcenc_find_best_partitioning.cpp", "diff": "@@ -112,8 +112,8 @@ static void compute_rgb_range(\nint partition_count = pt->partition_count;\nfor (int i = 0; i < partition_count; i++)\n{\n- rgb_min[i] = float3(1e38f, 1e38f, 1e38f);\n- rgb_max[i] = float3(-1e38f, -1e38f, -1e38f);\n+ rgb_min[i] = float3(1e38f);\n+ rgb_max[i] = float3(-1e38f);\n}\nfor (int i = 0; i < texels_per_block; i++)\n@@ -193,7 +193,7 @@ void compute_partition_error_color_weightings(\nfor (int i = 0; i < pcnt; i++)\n{\n- error_weightings[i] = float4(1e-12f, 1e-12f, 1e-12f, 1e-12f);\n+ error_weightings[i] = float4(1e-12f);\n}\nfor (int i = 0; i < texels_per_block; i++)\n@@ -328,7 +328,7 @@ void find_best_partitionings(\nuncorr_lines[j].a = averages[j];\nif (dot(directions_rgba[j], directions_rgba[j]) == 0.0f)\n{\n- uncorr_lines[j].b = normalize(float4(1.0f, 1.0f, 1.0f, 1.0f));\n+ uncorr_lines[j].b = normalize(float4(1.0f));\n}\nelse\n{\n@@ -339,10 +339,10 @@ void find_best_partitionings(\nproc_uncorr_lines[j].bs = (uncorr_lines[j].b * color_scalefactors[j]);\nproc_uncorr_lines[j].bis = (uncorr_lines[j].b * inverse_color_scalefactors[j]);\n- samechroma_lines[j].a = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ samechroma_lines[j].a = float4(0.0f);\nif (dot(averages[j], averages[j]) == 0.0f)\n{\n- samechroma_lines[j].b = normalize(float4(1.0f, 1.0f, 1.0f, 1.0f));\n+ samechroma_lines[j].b = normalize(float4(1.0f));\n}\nelse\n{\n@@ -418,7 +418,7 @@ void find_best_partitionings(\nfloat uncorr_error = 0.0f;\nfloat samechroma_error = 0.0f;\n- float4 separate_error = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 separate_error = float4(0.0f);\ncompute_error_squared_rgba(ptab + partition,\nblk,\newb,\n@@ -592,17 +592,17 @@ void find_best_partitionings(\nuncorr_lines[j].a = averages[j];\nif (dot(directions_rgb[j], directions_rgb[j]) == 0.0f)\n{\n- uncorr_lines[j].b = normalize(float3(1.0f, 1.0f, 1.0f));\n+ uncorr_lines[j].b = normalize(float3(1.0f));\n}\nelse\n{\nuncorr_lines[j].b = normalize(directions_rgb[j]);\n}\n- samechroma_lines[j].a = float3(0.0f, 0.0f, 0.0f);\n+ samechroma_lines[j].a = float3(0.0f);\nif (dot(averages[j], averages[j]) == 0.0f)\n{\n- samechroma_lines[j].b = normalize(float3(1.0f, 1.0f, 1.0f));\n+ samechroma_lines[j].b = normalize(float3(1.0f));\n}\nelse\n{\n@@ -621,7 +621,7 @@ void find_best_partitionings(\nfloat2 dirs_gb = float2(directions_rgb[j].g, directions_rgb[j].b);\nif (dot(dirs_gb, dirs_gb) == 0.0f)\n{\n- separate_red_lines[j].b = normalize(float2(1.0f, 1.0f));\n+ separate_red_lines[j].b = normalize(float2(1.0f));\n}\nelse\n{\n@@ -632,7 +632,7 @@ void find_best_partitionings(\nfloat2 dirs_rb = float2(directions_rgb[j].r, directions_rgb[j].b);\nif (dot(dirs_rb, dirs_rb) == 0.0f)\n{\n- separate_green_lines[j].b = normalize(float2(1.0f, 1.0f));\n+ separate_green_lines[j].b = normalize(float2(1.0f));\n}\nelse\n{\n@@ -643,7 +643,7 @@ void find_best_partitionings(\nfloat2 dirs_rg = float2(directions_rgb[j].r, directions_rgb[j].g);\nif (dot(dirs_rg, dirs_rg) == 0.0f)\n{\n- separate_blue_lines[j].b = normalize(float2(1.0f, 1.0f));\n+ separate_blue_lines[j].b = normalize(float2(1.0f));\n}\nelse\n{\n@@ -665,7 +665,7 @@ void find_best_partitionings(\nfloat uncorr_error = 0.0f;\nfloat samechroma_error = 0.0f;\n- float3 separate_error = float3(0.0f, 0.0f, 0.0f);\n+ float3 separate_error = float3(0.0f);\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": "@@ -266,7 +266,7 @@ static void compute_endpoints_and_ideal_weights_2_components(\n{\nfloat2 egv = directions[i];\nif (egv.r + egv.g < 0.0f)\n- directions[i] = float2(0.0f, 0.0f) - egv;\n+ directions[i] = float2(0.0f) - egv;\n}\nfor (int i = 0; i < partition_count; i++)\n@@ -274,7 +274,7 @@ static void compute_endpoints_and_ideal_weights_2_components(\nlines[i].a = averages[i];\nif (dot(directions[i], directions[i]) == 0.0f)\n{\n- lines[i].b = normalize(float2(1.0f, 1.0f));\n+ lines[i].b = normalize(float2(1.0f));\n}\nelse\n{\n@@ -517,7 +517,7 @@ static void compute_endpoints_and_ideal_weights_3_components(\nfloat3 direc = directions[i];\nif (direc.r + direc.g + direc.b < 0.0f)\n{\n- directions[i] = float3(0.0f, 0.0f, 0.0f) - direc;\n+ directions[i] = float3(0.0f) - direc;\n}\n}\n@@ -526,7 +526,7 @@ static void compute_endpoints_and_ideal_weights_3_components(\nlines[i].a = averages[i];\nif (dot(directions[i], directions[i]) == 0.0f)\n{\n- lines[i].b = normalize(float3(1.0f, 1.0f, 1.0f));\n+ lines[i].b = normalize(float3(1.0f));\n}\nelse\n{\n@@ -713,7 +713,7 @@ static void compute_endpoints_and_ideal_weights_rgba(\nfloat4 direc = directions_rgba[i];\nif (direc.r + direc.g + direc.b < 0.0f)\n{\n- directions_rgba[i] = float4(0.0f, 0.0f, 0.0f, 0.0f) - direc;\n+ directions_rgba[i] = float4(0.0f) - direc;\n}\n}\n@@ -722,7 +722,7 @@ static void compute_endpoints_and_ideal_weights_rgba(\nlines[i].a = averages[i];\nif (dot(directions_rgba[i], directions_rgba[i]) == 0.0f)\n{\n- lines[i].b = normalize(float4(1.0f, 1.0f, 1.0f, 1.0f));\n+ lines[i].b = normalize(float4(1.0f));\n}\nelse\n{\n@@ -1284,8 +1284,8 @@ void recompute_ideal_colors(\nfor (int i = 0; i < partition_count; i++)\n{\n- float4 rgba_sum = float4(1e-17f, 1e-17f, 1e-17f, 1e-17f);\n- float4 rgba_weight_sum = float4(1e-17f, 1e-17f, 1e-17f, 1e-17f);\n+ float4 rgba_sum = float4(1e-17f);\n+ float4 rgba_weight_sum = float4(1e-17f);\nint texelcount = pi->texels_per_partition[i];\nconst uint8_t *texel_indexes = pi->texels_of_partition[i];\n@@ -1313,22 +1313,22 @@ void recompute_ideal_colors(\nfloat wmin2 = 1.0f;\nfloat wmax2 = 0.0f;\n- float4 left_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 middle_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 right_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 left_sum = float4(0.0f);\n+ float4 middle_sum = float4(0.0f);\n+ float4 right_sum = float4(0.0f);\n- float4 left2_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 middle2_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 right2_sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 left2_sum = float4(0.0f);\n+ float4 middle2_sum = float4(0.0f);\n+ float4 right2_sum = float4(0.0f);\n- float3 lmrs_sum = float3(0.0f, 0.0f, 0.0f);\n+ float3 lmrs_sum = float3(0.0f);\n- float4 color_vec_x = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- float4 color_vec_y = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ float4 color_vec_x = float4(0.0f);\n+ float4 color_vec_y = float4(0.0f);\n- float2 scale_vec = float2(0.0f, 0.0f);\n+ float2 scale_vec = float2(0.0f);\n- float3 weight_weight_sum = float3(1e-17f, 1e-17f, 1e-17f);\n+ float3 weight_weight_sum = float3(1e-17f);\nfloat psum = 1e-17f;\n// FIXME: the loop below has too many responsibilities, making it inefficient.\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenccli_error_metrics.cpp", "new_path": "Source/astcenccli_error_metrics.cpp", "diff": "@@ -45,8 +45,8 @@ public:\n* @brief Create a new Kahan accumulator\n*/\nkahan_accum4() {\n- sum = float4(0.0f, 0.0f, 0.0f, 0.0f);\n- comp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n+ sum = float4(0.0f);\n+ comp = float4(0.0f);\n}\n};\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Use new scalar initializer for template vectors
61,745
09.11.2020 13:54:10
0
9134d7bb16cbad77f0b46e7a436bb69d8d1b75cf
Add functional tests to GitHub Jenkins runner
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -46,9 +46,10 @@ pipeline {\n}\nstage('Test') {\nsteps {\n- sh 'python3 ./Test/astc_test_image.py --encoder=all --test-set Small'\n- //perfReport(sourceDataFiles:'TestOutput/results.xml')\n- //junit(testResults: 'TestOutput/results.xml')\n+ sh '''\n+ python3 ./Test/astc_test_functional.py\n+ python3 ./Test/astc_test_image.py --encoder=all --test-set Small\n+ '''\n}\n}\n}\n@@ -95,10 +96,9 @@ pipeline {\nsteps {\nbat '''\nset Path=c:\\\\Python38;c:\\\\Python38\\\\Scripts;%Path%\n+ call python ./Test/astc_test_functional.py\ncall python ./Test/astc_test_image.py --test-set Small\n'''\n- //perfReport(sourceDataFiles:'TestOutput\\\\results.xml')\n- //junit(testResults: 'TestOutput\\\\results.xml')\n}\n}\n}\n@@ -135,10 +135,9 @@ pipeline {\nsteps {\nsh '''\nexport PATH=/usr/local/bin:$PATH\n+ python3 ./Test/astc_test_functional.py\npython3 ./Test/astc_test_image.py --test-set Small\n'''\n- //perfReport(sourceDataFiles:'TestOutput/results.xml')\n- //junit(testResults: 'TestOutput/results.xml')\n}\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add functional tests to GitHub Jenkins runner
61,745
09.11.2020 14:24:00
0
454a3842bc4daed3e262428b4431eef34a7ccade
Add imagemagick to Docker image for Linux testing
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Dockerfile", "new_path": "jenkins/build.Dockerfile", "diff": "FROM ubuntu:18.04\n-LABEL build.environment.version=\"2.0.0\"\n+LABEL build.environment.version=\"2.1.0\"\nRUN useradd -u 1001 -U -m -c Jenkins jenkins\n@@ -9,6 +9,7 @@ RUN apt update && apt-get install -y \\\ng++ \\\ngcc \\\ngit \\\n+ imagemagick \\\nmake \\\npython3 \\\npython3-junit.xml \\\n" }, { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -14,7 +14,7 @@ pipeline {\nstage('Linux') {\nagent {\ndocker {\n- image 'astcenc:2.0.0'\n+ image 'astcenc:2.1.0'\nregistryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\nregistryCredentialsId 'cepe-artifactory-jenkins'\nlabel 'docker'\n@@ -96,14 +96,13 @@ pipeline {\nsteps {\nbat '''\nset Path=c:\\\\Python38;c:\\\\Python38\\\\Scripts;%Path%\n- call python ./Test/astc_test_functional.py\ncall python ./Test/astc_test_image.py --test-set Small\n'''\n}\n}\n}\n}\n- /* Build for Mac on x86_64 */\n+ /* Build for macOS on x86_64 */\nstage('macOS') {\nagent {\nlabel 'mac && x86_64'\n@@ -135,7 +134,6 @@ pipeline {\nsteps {\nsh '''\nexport PATH=/usr/local/bin:$PATH\n- python3 ./Test/astc_test_functional.py\npython3 ./Test/astc_test_image.py --test-set Small\n'''\n}\n@@ -147,7 +145,7 @@ pipeline {\nstage('Artifactory') {\nagent {\ndocker {\n- image 'astcenc:2.0.0'\n+ image 'astcenc:2.1.0'\nregistryUrl 'https://mobile-studio--docker.artifactory.geo.arm.com'\nregistryCredentialsId 'cepe-artifactory-jenkins'\nlabel 'docker'\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add imagemagick to Docker image for Linux testing
61,745
11.11.2020 21:03:03
0
9cd806ae181c9e2275343d7fe2c6149484846def
Misc small cleanups
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_mathlib.h", "new_path": "Source/astcenc_mathlib.h", "diff": "#ifndef ASTC_MATHLIB_H_INCLUDED\n#define ASTC_MATHLIB_H_INCLUDED\n+#include <cassert>\n#include <cstdint>\n#include <cmath>\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_result_plot.py", "new_path": "Test/astc_test_result_plot.py", "diff": "@@ -169,7 +169,9 @@ def plot(results, chartRows, chartCols, blockSizes,\nfig.delaxes(axs[i][j])\ncontinue\n- if len(chartCols) == 1:\n+ if len(chartRows) == 1 and len(chartCols) == 1:\n+ ax = axs\n+ elif len(chartCols) == 1:\nax = axs[i]\nelse:\nax = axs[i, j]\n@@ -215,7 +217,9 @@ def plot(results, chartRows, chartCols, blockSizes,\nfor i, row in enumerate(chartRows):\nfor j, col in enumerate(chartCols):\n- if len(chartCols) == 1:\n+ if len(chartRows) == 1 and len(chartCols) == 1:\n+ ax = axs\n+ elif len(chartCols) == 1:\nax = axs[i]\nelse:\nax = axs[i, j]\n@@ -241,6 +245,16 @@ def main():\ncharts = [\n[\n+ # Plot headline 1.7 to 2.1 scores\n+ [\"medium\"],\n+ [\"ref-2.1-avx2\"],\n+ [\"4x4\", \"6x6\", \"8x8\"],\n+ True,\n+ \"ref-1.7\",\n+ None,\n+ \"relative-1.7-to-2.1.png\",\n+ (8, None)\n+ ], [\n# --------------------------------------------------------\n# Plot all absolute scores\n[\"thorough\", \"medium\", \"fast\", \"fastest\"],\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Misc small cleanups
61,745
11.11.2020 23:01:14
0
9b5459eb8fead033e78bb2ab011d23b38b5f9102
Remove old comment about IQ loss
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_compress_symbolic.cpp", "new_path": "Source/astcenc_compress_symbolic.cpp", "diff": "@@ -190,13 +190,6 @@ static int realign_weights(\nweight_set8[we_idx] = (uint8_t)((prev_and_next >> 16) & 0xFF);\nadjustments++;\n}\n-\n- // IQ loss: The v1 compressor iterated here multiple times, trying\n- // multiple increments or decrements until the error stopped\n- // improving. This was very expensive (~15% of the v1 compressor\n- // coding time) for very small improvements in quality (typically\n- // less than 0.005 dB PSNR), so we now only check one step in\n- // either direction\n}\n// Prepare iteration for plane 2\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove old comment about IQ loss
61,745
13.11.2020 14:02:25
0
207ccd9972b879c015e4a11785b584158c753525
Only swizzle on demand
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_image.cpp", "new_path": "Source/astcenc_image.cpp", "diff": "@@ -293,13 +293,17 @@ void fetch_imageblock(\nzpos += img.dim_pad;\n}\n- float data[6];\n- data[4] = 0;\n- data[5] = 1;\n+ // True if any non-identity swizzle\n+ bool needs_swz = (swz.r != ASTCENC_SWZ_R) || (swz.g != ASTCENC_SWZ_G) ||\n+ (swz.b != ASTCENC_SWZ_B) || (swz.a != ASTCENC_SWZ_A);\nint idx = 0;\nif (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+\nuint8_t*** data8 = static_cast<uint8_t***>(img.data);\nfor (int z = 0; z < bsd->zdim; z++)\n{\n@@ -329,15 +333,23 @@ void fetch_imageblock(\nint b = data8[zi][yi][4 * xi + 2];\nint a = data8[zi][yi][4 * xi + 3];\n- data[0] = r / 255.0f;\n- data[1] = g / 255.0f;\n- data[2] = b / 255.0f;\n- data[3] = a / 255.0f;\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+\n+ r = data[swz.r];\n+ g = data[swz.g];\n+ b = data[swz.b];\n+ a = data[swz.a];\n+ }\n- pb->data_r[idx] = data[swz.r];\n- pb->data_g[idx] = data[swz.g];\n- pb->data_b[idx] = data[swz.b];\n- pb->data_a[idx] = data[swz.a];\n+ pb->data_r[idx] = r / 255.0f;\n+ pb->data_g[idx] = g / 255.0f;\n+ pb->data_b[idx] = b / 255.0f;\n+ pb->data_a[idx] = a / 255.0f;\nidx++;\n}\n}\n@@ -345,6 +357,10 @@ void fetch_imageblock(\n}\nelse 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+\nuint16_t*** data16 = static_cast<uint16_t***>(img.data);\nfor (int z = 0; z < bsd->zdim; z++)\n{\n@@ -374,26 +390,23 @@ void fetch_imageblock(\nint b = data16[zi][yi][4 * xi + 2];\nint a = data16[zi][yi][4 * xi + 3];\n- float rf = sf16_to_float(r);\n- float gf = sf16_to_float(g);\n- float bf = sf16_to_float(b);\n- float af = sf16_to_float(a);\n-\n- // equalize the color components somewhat, and get rid of negative values.\n- rf = MAX(rf, 1e-8f);\n- gf = MAX(gf, 1e-8f);\n- bf = MAX(bf, 1e-8f);\n- af = MAX(af, 1e-8f);\n-\n- data[0] = rf;\n- data[1] = gf;\n- data[2] = bf;\n- data[3] = af;\n-\n- pb->data_r[idx] = data[swz.r];\n- pb->data_g[idx] = data[swz.g];\n- pb->data_b[idx] = data[swz.b];\n- pb->data_a[idx] = data[swz.a];\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+\n+ r = data[swz.r];\n+ g = data[swz.g];\n+ b = data[swz.b];\n+ a = data[swz.a];\n+ }\n+\n+ pb->data_r[idx] = MAX(sf16_to_float(r), 1e-8f);\n+ pb->data_g[idx] = MAX(sf16_to_float(g), 1e-8f);\n+ pb->data_b[idx] = MAX(sf16_to_float(b), 1e-8f);\n+ pb->data_a[idx] = MAX(sf16_to_float(a), 1e-8f);\nidx++;\n}\n}\n@@ -402,6 +415,11 @@ void fetch_imageblock(\nelse // if (img.data_type == ASTCENC_TYPE_F32)\n{\nassert(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+\nfloat*** data32 = static_cast<float***>(img.data);\nfor (int z = 0; z < bsd->zdim; z++)\n{\n@@ -431,16 +449,23 @@ void fetch_imageblock(\nfloat b = data32[zi][yi][4 * xi + 2];\nfloat a = data32[zi][yi][4 * xi + 3];\n- // equalize the color components somewhat, and get rid of negative values.\n- data[0] = MAX(r, 1e-8f);\n- data[1] = MAX(g, 1e-8f);\n- data[2] = MAX(b, 1e-8f);\n- data[3] = MAX(a, 1e-8f);\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+\n+ r = data[swz.r];\n+ g = data[swz.g];\n+ b = data[swz.b];\n+ a = data[swz.a];\n+ }\n- pb->data_r[idx] = data[swz.r];\n- pb->data_g[idx] = data[swz.g];\n- pb->data_b[idx] = data[swz.b];\n- pb->data_a[idx] = data[swz.a];\n+ pb->data_r[idx] = MAX(r, 1e-8f);\n+ pb->data_g[idx] = MAX(g, 1e-8f);\n+ pb->data_b[idx] = MAX(b, 1e-8f);\n+ pb->data_a[idx] = MAX(a, 1e-8f);\nidx++;\n}\n}\n@@ -478,8 +503,16 @@ void write_imageblock(\nint zsize = img.dim_z;\nfloat data[7];\n- data[4] = 0.0f;\n- data[5] = 1.0f;\n+ data[ASTCENC_SWZ_0] = 0.0f;\n+ data[ASTCENC_SWZ_1] = 1.0f;\n+\n+ // True if any non-identity swizzle\n+ bool needs_swz = (swz.r != ASTCENC_SWZ_R) || (swz.g != ASTCENC_SWZ_G) ||\n+ (swz.b != ASTCENC_SWZ_B) || (swz.a != ASTCENC_SWZ_A);\n+\n+ // True if any swizzle uses Z reconstruct\n+ bool needs_z = (swz.r == ASTCENC_SWZ_Z) || (swz.g == ASTCENC_SWZ_Z) ||\n+ (swz.b == ASTCENC_SWZ_Z) || (swz.a == ASTCENC_SWZ_Z);\nint idx = 0;\nif (img.data_type == ASTCENC_TYPE_U8)\n@@ -497,21 +530,25 @@ void write_imageblock(\nif (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n{\n+ int ri, gi, bi, ai;\n+\nif (*nptr)\n{\n// NaN-pixel, but we can't display it. Display purple instead.\n- data8[zi][yi][4 * xi ] = 0xFF;\n- data8[zi][yi][4 * xi + 1] = 0x00;\n- data8[zi][yi][4 * xi + 2] = 0xFF;\n- data8[zi][yi][4 * xi + 3] = 0xFF;\n+ ri = 0xFF;\n+ gi = 0x00;\n+ bi = 0xFF;\n+ ai = 0xFF;\n}\n- else\n+ else if (needs_swz)\n{\n- data[0] = pb->data_r[idx];\n- data[1] = pb->data_g[idx];\n- data[2] = pb->data_b[idx];\n- data[3] = pb->data_a[idx];\n+ data[ASTCENC_SWZ_R] = pb->data_r[idx];\n+ data[ASTCENC_SWZ_G] = pb->data_g[idx];\n+ data[ASTCENC_SWZ_B] = pb->data_b[idx];\n+ data[ASTCENC_SWZ_A] = pb->data_a[idx];\n+ if (needs_z)\n+ {\nfloat xcoord = (data[0] * 2.0f) - 1.0f;\nfloat ycoord = (data[3] * 2.0f) - 1.0f;\nfloat zcoord = 1.0f - xcoord * xcoord - ycoord * ycoord;\n@@ -519,41 +556,27 @@ void write_imageblock(\n{\nzcoord = 0.0f;\n}\n- data[6] = (astc::sqrt(zcoord) * 0.5f) + 0.5f;\n-\n- // clamp to [0,1]\n- if (data[0] > 1.0f)\n- {\n- data[0] = 1.0f;\n- }\n-\n- if (data[1] > 1.0f)\n- {\n- data[1] = 1.0f;\n+ data[ASTCENC_SWZ_Z] = (astc::sqrt(zcoord) * 0.5f) + 0.5f;\n}\n- if (data[2] > 1.0f)\n- {\n- data[2] = 1.0f;\n+ ri = astc::flt2int_rtn(MIN(data[swz.r], 1.0f) * 255.0f);\n+ gi = astc::flt2int_rtn(MIN(data[swz.g], 1.0f) * 255.0f);\n+ bi = astc::flt2int_rtn(MIN(data[swz.b], 1.0f) * 255.0f);\n+ ai = astc::flt2int_rtn(MIN(data[swz.a], 1.0f) * 255.0f);\n}\n-\n- if (data[3] > 1.0f)\n+ else\n{\n- data[3] = 1.0f;\n+ ri = astc::flt2int_rtn(MIN(pb->data_r[idx], 1.0f) * 255.0f);\n+ gi = astc::flt2int_rtn(MIN(pb->data_g[idx], 1.0f) * 255.0f);\n+ bi = astc::flt2int_rtn(MIN(pb->data_b[idx], 1.0f) * 255.0f);\n+ ai = astc::flt2int_rtn(MIN(pb->data_a[idx], 1.0f) * 255.0f);\n}\n- // pack the data\n- int ri = astc::flt2int_rtn(data[swz.r] * 255.0f);\n- int gi = astc::flt2int_rtn(data[swz.g] * 255.0f);\n- int bi = astc::flt2int_rtn(data[swz.b] * 255.0f);\n- int ai = astc::flt2int_rtn(data[swz.a] * 255.0f);\n-\ndata8[zi][yi][4 * xi ] = ri;\ndata8[zi][yi][4 * xi + 1] = gi;\ndata8[zi][yi][4 * xi + 2] = bi;\ndata8[zi][yi][4 * xi + 3] = ai;\n}\n- }\nidx++;\nnptr++;\n}\n@@ -575,20 +598,24 @@ void write_imageblock(\nif (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n{\n+ int ri, gi, bi, ai;\n+\nif (*nptr)\n{\n- data16[zi][yi][4 * xi ] = 0xFFFF;\n- data16[zi][yi][4 * xi + 1] = 0xFFFF;\n- data16[zi][yi][4 * xi + 2] = 0xFFFF;\n- data16[zi][yi][4 * xi + 3] = 0xFFFF;\n+ ri = 0xFFFF;\n+ gi = 0xFFFF;\n+ bi = 0xFFFF;\n+ ai = 0xFFFF;\n}\n- else\n+ else if (needs_swz)\n{\n- data[0] = pb->data_r[idx];\n- data[1] = pb->data_g[idx];\n- data[2] = pb->data_b[idx];\n- data[3] = pb->data_a[idx];\n+ data[ASTCENC_SWZ_R] = pb->data_r[idx];\n+ data[ASTCENC_SWZ_G] = pb->data_g[idx];\n+ data[ASTCENC_SWZ_B] = pb->data_b[idx];\n+ data[ASTCENC_SWZ_A] = pb->data_a[idx];\n+ if (needs_z)\n+ {\nfloat xN = (data[0] * 2.0f) - 1.0f;\nfloat yN = (data[3] * 2.0f) - 1.0f;\nfloat zN = 1.0f - xN * xN - yN * yN;\n@@ -596,18 +623,26 @@ void write_imageblock(\n{\nzN = 0.0f;\n}\n- data[6] = (astc::sqrt(zN) * 0.5f) + 0.5f;\n-\n- int r = float_to_sf16(data[swz.r], SF_NEARESTEVEN);\n- int g = float_to_sf16(data[swz.g], SF_NEARESTEVEN);\n- int b = float_to_sf16(data[swz.b], SF_NEARESTEVEN);\n- int a = float_to_sf16(data[swz.a], SF_NEARESTEVEN);\n+ data[ASTCENC_SWZ_Z] = (astc::sqrt(zN) * 0.5f) + 0.5f;\n+ }\n- data16[zi][yi][4 * xi ] = r;\n- data16[zi][yi][4 * xi + 1] = g;\n- data16[zi][yi][4 * xi + 2] = b;\n- data16[zi][yi][4 * xi + 3] = a;\n+ ri = float_to_sf16(data[swz.r], SF_NEARESTEVEN);\n+ gi = float_to_sf16(data[swz.g], SF_NEARESTEVEN);\n+ bi = float_to_sf16(data[swz.b], SF_NEARESTEVEN);\n+ ai = float_to_sf16(data[swz.a], SF_NEARESTEVEN);\n}\n+ else\n+ {\n+ ri = float_to_sf16(pb->data_r[idx], SF_NEARESTEVEN);\n+ gi = float_to_sf16(pb->data_g[idx], SF_NEARESTEVEN);\n+ bi = float_to_sf16(pb->data_b[idx], SF_NEARESTEVEN);\n+ ai = float_to_sf16(pb->data_a[idx], SF_NEARESTEVEN);\n+ }\n+\n+ data16[zi][yi][4 * xi ] = ri;\n+ data16[zi][yi][4 * xi + 1] = gi;\n+ data16[zi][yi][4 * xi + 2] = bi;\n+ data16[zi][yi][4 * xi + 3] = ai;\n}\nidx++;\nnptr++;\n@@ -631,20 +666,24 @@ void write_imageblock(\nif (xi >= 0 && yi >= 0 && zi >= 0 && xi < xsize && yi < ysize && zi < zsize)\n{\n+ float rf, gf, bf, af;\n+\nif (*nptr)\n{\n- data32[zi][yi][4 * xi ] = std::numeric_limits<float>::quiet_NaN();\n- data32[zi][yi][4 * xi + 1] = std::numeric_limits<float>::quiet_NaN();\n- data32[zi][yi][4 * xi + 2] = std::numeric_limits<float>::quiet_NaN();\n- data32[zi][yi][4 * xi + 3] = std::numeric_limits<float>::quiet_NaN();\n+ rf = std::numeric_limits<float>::quiet_NaN();\n+ gf = std::numeric_limits<float>::quiet_NaN();\n+ bf = std::numeric_limits<float>::quiet_NaN();\n+ af = std::numeric_limits<float>::quiet_NaN();\n}\n- else\n+ else if (needs_swz)\n{\n- data[0] = pb->data_r[idx];\n- data[1] = pb->data_g[idx];\n- data[2] = pb->data_b[idx];\n- data[3] = pb->data_a[idx];\n+ data[ASTCENC_SWZ_R] = pb->data_r[idx];\n+ data[ASTCENC_SWZ_G] = pb->data_g[idx];\n+ data[ASTCENC_SWZ_B] = pb->data_b[idx];\n+ data[ASTCENC_SWZ_A] = pb->data_a[idx];\n+ if (needs_z)\n+ {\nfloat xN = (data[0] * 2.0f) - 1.0f;\nfloat yN = (data[3] * 2.0f) - 1.0f;\nfloat zN = 1.0f - xN * xN - yN * yN;\n@@ -652,13 +691,26 @@ void write_imageblock(\n{\nzN = 0.0f;\n}\n- data[6] = (astc::sqrt(zN) * 0.5f) + 0.5f;\n+ data[ASTCENC_SWZ_Z] = (astc::sqrt(zN) * 0.5f) + 0.5f;\n+ }\n- data32[zi][yi][4 * xi ] = data[swz.r];\n- data32[zi][yi][4 * xi + 1] = data[swz.g];\n- data32[zi][yi][4 * xi + 2] = data[swz.b];\n- data32[zi][yi][4 * xi + 3] = data[swz.a];\n+ rf = data[swz.r];\n+ gf = data[swz.g];\n+ bf = data[swz.b];\n+ af = data[swz.a];\n+ }\n+ else\n+ {\n+ rf = pb->data_r[idx];\n+ gf = pb->data_g[idx];\n+ bf = pb->data_b[idx];\n+ af = pb->data_a[idx];\n}\n+\n+ data32[zi][yi][4 * xi ] = rf;\n+ data32[zi][yi][4 * xi + 1] = gf;\n+ data32[zi][yi][4 * xi + 2] = bf;\n+ data32[zi][yi][4 * xi + 3] = af;\n}\nidx++;\nnptr++;\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Only swizzle on demand
61,745
13.11.2020 16:30:48
0
2164984243a3fbd2b2429e7562f7fe31914f446b
Update docs for 2.1 release
[ { "change_type": "MODIFY", "old_path": "Docs/ChangeLog.md", "new_path": "Docs/ChangeLog.md", "diff": "@@ -6,9 +6,15 @@ release of the 2.x series.\nAll performance data on this page is measured on an Intel Core i5-9600K\nclocked at 4.2 GHz, running astcenc using 6 threads.\n+## 2.2\n+\n+**Status:** :warning: In development (ETA February 2021)\n+\n+The 2.2 release is the third release in the 2.x series. It includes ...\n+\n## 2.1\n-**Status:** :warning: In development (ETA November 2020)\n+**Status:** Released, November 2020\nThe 2.1 release is the second release in the 2.x series. It includes a number\nof performance optimizations and new features.\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -62,7 +62,7 @@ Release build binaries for the `astcenc` stable releases are provided in the\n[GitHub Releases page](https://github.com/ARM-software/astc-encoder/releases).\nBinaries are provided for 64-bit builds on Windows, macOS, and Linux.\n-* Latest stable release: 2.0.\n+* Latest stable release: 2.1.\n* Change log: [2.x series](./Docs/ChangeLog.md)\n## astcenc 2.x binaries\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Update docs for 2.1 release
61,745
13.11.2020 17:47:22
0
26d5ce9dd55e8f941fe4a38dd730428a256616ef
Bump master version to 2.2-develop
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "#include \"astcenccli_internal.h\"\nconst char *astcenc_copyright_string =\n-R\"(ASTC codec v2.1, %u-bit %s%s\n+R\"(ASTC codec v2.2-develop, %u-bit %s%s\nCopyright 2011-2020 Arm Limited, all rights reserved\n)\";\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Bump master version to 2.2-develop
61,745
17.11.2020 08:48:00
0
5d3eea1576dd6a6b379fa02f3799f9158dcb7cda
Change requirement on SSE 4.2 to SSE 4.1 (CI)
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -32,7 +32,7 @@ pipeline {\nsh '''\ncd ./Source/\nmake CXX=clang++ VEC=avx2\n- make CXX=clang++ VEC=sse4.2\n+ make CXX=clang++ VEC=sse4.1\nmake CXX=clang++ VEC=sse2\n'''\n}\n@@ -70,7 +70,7 @@ pipeline {\nbat '''\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\ncall msbuild .\\\\Source\\\\VS2019\\\\astcenc-avx2.vcxproj /p:Configuration=Release /p:Platform=x64\n- call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse4.2.vcxproj /p:Configuration=Release /p:Platform=x64\n+ call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse4.1.vcxproj /p:Configuration=Release /p:Platform=x64\ncall msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse2.vcxproj /p:Configuration=Release /p:Platform=x64\n'''\n}\n@@ -80,7 +80,7 @@ pipeline {\nbat '''\ncall c:\\\\progra~2\\\\micros~1\\\\2019\\\\buildtools\\\\vc\\\\auxiliary\\\\build\\\\vcvars64.bat\ncall msbuild .\\\\Source\\\\VS2019\\\\astcenc-avx2.vcxproj /p:Configuration=Debug /p:Platform=x64\n- call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse4.2.vcxproj /p:Configuration=Debug /p:Platform=x64\n+ call msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse4.1.vcxproj /p:Configuration=Debug /p:Platform=x64\ncall msbuild .\\\\Source\\\\VS2019\\\\astcenc-sse2.vcxproj /p:Configuration=Debug /p:Platform=x64\n'''\n}\n@@ -118,7 +118,7 @@ pipeline {\nsh '''\ncd ./Source/\nmake VEC=avx2\n- make VEC=sse4.2\n+ make VEC=sse4.1\nmake VEC=sse2\n'''\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Change requirement on SSE 4.2 to SSE 4.1 (CI)
61,745
17.11.2020 23:41:33
0
8180b0ff90e7b20345bc3a7d98bff556357a9bb4
Add note on using -cw to the -esw help text
[ { "change_type": "MODIFY", "old_path": "Source/astcenccli_toplevel_help.cpp", "new_path": "Source/astcenccli_toplevel_help.cpp", "diff": "@@ -363,9 +363,17 @@ ADVANCED COMPRESSION\nzero or one. For example to swap the RG channels, and replace\nalpha with 1, the swizzle 'grb1' should be used.\n- Note that the input swizzle is assumed to take place before any\n- compression, and all error weighting applies to the post-swizzle\n- channel ordering.\n+ The input swizzle takes place before any compression, and all\n+ error weighting applied using the -cw option is applied to the\n+ post-swizzle channel ordering.\n+\n+ By default all 4 post-swizzle channels are included in the error\n+ metrics during compression. When using -esw to map two channel\n+ data to the L+A endpoint (e.g. -esw rrrg) the luminance data\n+ stored in the rgb channels will be weighted three times more\n+ strongly than the alpha channel. This can be corrected using the\n+ -cw option to zero the weights of unused channels; e.g. using\n+ -cw 1 0 0 1.\n-dsw <swizzle>\nSwizzle the color components after decompression. The swizzle is\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add note on using -cw to the -esw help text
61,745
19.11.2020 14:02:57
0
83fe69d274094649570ab1f9c89ad58be7165ff8
Make a generic "none" no-SIMD target for testing
[ { "change_type": "MODIFY", "old_path": "Source/Makefile", "new_path": "Source/Makefile", "diff": "@@ -28,7 +28,7 @@ APP ?= astcenc\n# Configure the SIMD ISA and intrinsics support; valid values are:\n#\n-# * neon - compile for Arm aarch64 + NEON\n+# * none - compile for generic C++ (set compiler using CXX)\n# * sse2 - allow use of x86-64 + sse2\n# * sse4.1 - allow use of x86-64 + sse4.1 and popcnt\n# * avx2 - allow use of x86-64 + avx2, sse4.1, and popcnt\n@@ -97,6 +97,9 @@ HEADERS = \\\nastcenc_internal.h \\\nastcenc_mathlib.h \\\nastcenc_vecmathlib.h \\\n+ astcenc_vecmathlib_none_1.h \\\n+ astcenc_vecmathlib_sse_4.h \\\n+ astcenc_vecmathlib_avx2_8.h \\\nastcenccli_internal.h \\\nstb_image.h \\\nstb_image_write.h \\\n@@ -143,7 +146,7 @@ endif\nendif\n# Validate that the VEC parameter is a supported value, and patch CXXFLAGS\n-ifeq ($(VEC),neon)\n+ifeq ($(VEC),none)\n# NEON is on by default; no enabled needed\nCXXFLAGS += -DASTCENC_SSE=0 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0 -DASTCENC_VECALIGN=16\nelse\n@@ -156,7 +159,7 @@ else\nifeq ($(VEC),avx2)\nCXXFLAGS += -mfpmath=sse -mavx2 -mpopcnt -DASTCENC_SSE=41 -DASTCENC_AVX=2 -DASTCENC_POPCNT=1 -DASTCENC_VECALIGN=32\nelse\n-$(error Unsupported VEC target, use VEC=neon/sse2/sse4.1/avx2)\n+$(error Unsupported VEC target, use VEC=none/sse2/sse4.1/avx2)\nendif\nendif\nendif\n@@ -225,13 +228,13 @@ clean:\n@echo \"[Clean] Removing $(VEC) build outputs\"\nbatchbuild:\n- # NEON is deliberately not here - needs a different CXX setting\n+ @+$(MAKE) -s VEC=none\n@+$(MAKE) -s VEC=sse2\n@+$(MAKE) -s VEC=sse4.1\n@+$(MAKE) -s VEC=avx2\nbatchclean:\n- @+$(MAKE) -s clean VEC=neon\n+ @+$(MAKE) -s clean VEC=none\n@+$(MAKE) -s clean VEC=sse2\n@+$(MAKE) -s clean VEC=sse4.1\n@+$(MAKE) -s clean VEC=avx2\n" }, { "change_type": "MODIFY", "old_path": "Test/astc_test_image.py", "new_path": "Test/astc_test_image.py", "diff": "@@ -328,7 +328,7 @@ def parse_command_line():\n\"ref-2.0-sse2\", \"ref-2.0-sse4.1\", \"ref-2.0-avx2\",\n\"ref-2.1-sse2\", \"ref-2.1-sse4.1\", \"ref-2.1-avx2\",\n\"ref-master-sse2\", \"ref-master-sse4.1\", \"ref-master-avx2\"]\n- testcoders = [\"sse2\", \"sse4.1\", \"avx2\"]\n+ testcoders = [\"none\", \"sse2\", \"sse4.1\", \"avx2\"]\ncoders = refcoders + testcoders + [\"all\", \"all-ref\"]\nparser.add_argument(\"--encoder\", dest=\"encoders\", default=\"avx2\",\nchoices=coders, help=\"test encoder variant\")\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Make a generic "none" no-SIMD target for testing
61,745
20.11.2020 16:02:44
0
efa6727d421a42b2f4724c49d6da08aae120c755
Add "none" build to CI
[ { "change_type": "MODIFY", "old_path": "jenkins/build.Jenkinsfile", "new_path": "jenkins/build.Jenkinsfile", "diff": "@@ -34,6 +34,7 @@ pipeline {\nmake CXX=clang++ VEC=avx2\nmake CXX=clang++ VEC=sse4.1\nmake CXX=clang++ VEC=sse2\n+ make CXX=clang++ VEC=none\n'''\n}\n}\n@@ -120,6 +121,7 @@ pipeline {\nmake VEC=avx2\nmake VEC=sse4.1\nmake VEC=sse2\n+ make VEC=none\n'''\n}\n}\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Add "none" build to CI
61,745
21.11.2020 00:00:28
0
4c5de4b2e7b0c64cb4379cc7adfe7d7d954e2648
Remove some unneeded vector casts
[ { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_avx2_8.h", "new_path": "Source/astcenc_vecmathlib_avx2_8.h", "diff": "@@ -471,10 +471,9 @@ ASTCENC_SIMD_INLINE vint8 select(vint8 a, vint8 b, vmask8 cond)\n// Don't use _mm256_blendv_epi8 directly, as it doesn't give the select on\n// float sign-bit in the mask behavior which is useful. Performance is the\n// same, these casts are free.\n- __m256i mask = _mm256_castps_si256(cond.m);\n__m256 av = _mm256_castsi256_ps(a.m);\n__m256 bv = _mm256_castsi256_ps(b.m);\n- return vint8(_mm256_castps_si256(_mm256_blendv_ps(av, bv, mask)));\n+ return vint8(_mm256_castps_si256(_mm256_blendv_ps(av, bv, cond.m)));\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "Source/astcenc_vecmathlib_sse_4.h", "new_path": "Source/astcenc_vecmathlib_sse_4.h", "diff": "@@ -502,10 +502,9 @@ ASTCENC_SIMD_INLINE vint4 select(vint4 a, vint4 b, vmask4 cond)\n// Don't use _mm_blendv_epi8 directly, as it doesn't give the select on\n// float sign-bit in the mask behavior which is useful. Performance is the\n// same, these casts are free.\n- __m128i mask = _mm_castps_si128(cond.m);\n__m128 av = _mm_castsi128_ps(a.m);\n__m128 bv = _mm_castsi128_ps(b.m);\n- return vint4(_mm_castps_si128(_mm_blendv_ps(av, bv, mask)));\n+ return vint4(_mm_castps_si128(_mm_blendv_ps(av, bv, cond.m)));\n#else\n__m128i d = _mm_srai_epi32(_mm_castps_si128(cond.m), 31);\nreturn vint4(_mm_or_si128(_mm_and_si128(d, b.m), _mm_andnot_si128(d, a.m)));\n" } ]
C
Apache License 2.0
arm-software/astc-encoder
Remove some unneeded vector casts