├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ └── reuse.yml ├── .gitignore ├── .reuse └── dep5 ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── LICENSES ├── Apache-2.0.txt └── CC-BY-4.0.txt ├── README.md ├── assembly ├── decoder.ts ├── generator.ts └── tsconfig.json ├── build ├── bc6hu-r11fg11fb10f_round.wasm ├── bc6hu-r11fg11fb10f_round.wat ├── bc6hu-r11fg11fb10f_round_noclamp.wasm ├── bc6hu-r11fg11fb10f_round_noclamp.wat ├── bc6hu-r11fg11fb10f_trunc.wasm ├── bc6hu-r11fg11fb10f_trunc.wat ├── bc6hu-rgb32f.wasm ├── bc6hu-rgb32f.wat ├── bc6hu-rgb9e5.wasm ├── bc6hu-rgb9e5.wat ├── bc6hu-rgba16f.wasm ├── bc6hu-rgba16f.wat ├── generator.wasm └── generator.wat ├── package-lock.json ├── package.json └── test └── test.ts /.gitattributes: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Khronos Group Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | *.wat text eol=lf 6 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Khronos Group Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | name: CI 6 | 7 | on: [push, pull_request] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [12.x, 14.x, 15.x] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Use Node.js ${{ matrix.node-version }} 21 | uses: actions/setup-node@v1 22 | with: 23 | node-version: ${{ matrix.node-version }} 24 | - run: npm install 25 | - run: npm run asbuild 26 | - run: npm test 27 | env: 28 | CI: true 29 | -------------------------------------------------------------------------------- /.github/workflows/reuse.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Khronos Group Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | name: REUSE Compliance 6 | 7 | on: [push, pull_request] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: REUSE Compliance Check 15 | uses: fsfe/reuse-action@v1 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The Khronos Group Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | node_modules 6 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: BC6H-Decoder-WASM 3 | Source: https://github.com/KhronosGroup/BC6H-Decoder-WASM 4 | 5 | Files: build/* 6 | Copyright: Copyright 2020 The Khronos Group Inc. 7 | License: Apache-2.0 8 | 9 | Files: *.json 10 | Copyright: Copyright 2020 The Khronos Group Inc. 11 | License: Apache-2.0 12 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | # Code of Conduct 6 | 7 | A reminder that this issue tracker is managed by the Khronos Group. 8 | Interactions here should follow the 9 | https://www.khronos.org/developers/code-of-conduct[Khronos Code of Conduct], 10 | which prohibits aggressive or derogatory language. Please keep the 11 | discussion friendly and civil. 12 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | 3 | Version 2.0, January 2004 4 | 5 | http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, 6 | AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | 11 | 12 | "License" shall mean the terms and conditions for use, reproduction, and distribution 13 | as defined by Sections 1 through 9 of this document. 14 | 15 | 16 | 17 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 18 | owner that is granting the License. 19 | 20 | 21 | 22 | "Legal Entity" shall mean the union of the acting entity and all other entities 23 | that control, are controlled by, or are under common control with that entity. 24 | For the purposes of this definition, "control" means (i) the power, direct 25 | or indirect, to cause the direction or management of such entity, whether 26 | by contract or otherwise, or (ii) ownership of fifty percent (50%) or more 27 | of the outstanding shares, or (iii) beneficial ownership of such entity. 28 | 29 | 30 | 31 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions 32 | granted by this License. 33 | 34 | 35 | 36 | "Source" form shall mean the preferred form for making modifications, including 37 | but not limited to software source code, documentation source, and configuration 38 | files. 39 | 40 | 41 | 42 | "Object" form shall mean any form resulting from mechanical transformation 43 | or translation of a Source form, including but not limited to compiled object 44 | code, generated documentation, and conversions to other media types. 45 | 46 | 47 | 48 | "Work" shall mean the work of authorship, whether in Source or Object form, 49 | made available under the License, as indicated by a copyright notice that 50 | is included in or attached to the work (an example is provided in the Appendix 51 | below). 52 | 53 | 54 | 55 | "Derivative Works" shall mean any work, whether in Source or Object form, 56 | that is based on (or derived from) the Work and for which the editorial revisions, 57 | annotations, elaborations, or other modifications represent, as a whole, an 58 | original work of authorship. For the purposes of this License, Derivative 59 | Works shall not include works that remain separable from, or merely link (or 60 | bind by name) to the interfaces of, the Work and Derivative Works thereof. 61 | 62 | 63 | 64 | "Contribution" shall mean any work of authorship, including the original version 65 | of the Work and any modifications or additions to that Work or Derivative 66 | Works thereof, that is intentionally submitted to Licensor for inclusion in 67 | the Work by the copyright owner or by an individual or Legal Entity authorized 68 | to submit on behalf of the copyright owner. For the purposes of this definition, 69 | "submitted" means any form of electronic, verbal, or written communication 70 | sent to the Licensor or its representatives, including but not limited to 71 | communication on electronic mailing lists, source code control systems, and 72 | issue tracking systems that are managed by, or on behalf of, the Licensor 73 | for the purpose of discussing and improving the Work, but excluding communication 74 | that is conspicuously marked or otherwise designated in writing by the copyright 75 | owner as "Not a Contribution." 76 | 77 | 78 | 79 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 80 | of whom a Contribution has been received by Licensor and subsequently incorporated 81 | within the Work. 82 | 83 | 2. Grant of Copyright License. Subject to the terms and conditions of this 84 | License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, 85 | no-charge, royalty-free, irrevocable copyright license to reproduce, prepare 86 | Derivative Works of, publicly display, publicly perform, sublicense, and distribute 87 | the Work and such Derivative Works in Source or Object form. 88 | 89 | 3. Grant of Patent License. Subject to the terms and conditions of this License, 90 | each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, 91 | no-charge, royalty-free, irrevocable (except as stated in this section) patent 92 | license to make, have made, use, offer to sell, sell, import, and otherwise 93 | transfer the Work, where such license applies only to those patent claims 94 | licensable by such Contributor that are necessarily infringed by their Contribution(s) 95 | alone or by combination of their Contribution(s) with the Work to which such 96 | Contribution(s) was submitted. If You institute patent litigation against 97 | any entity (including a cross-claim or counterclaim in a lawsuit) alleging 98 | that the Work or a Contribution incorporated within the Work constitutes direct 99 | or contributory patent infringement, then any patent licenses granted to You 100 | under this License for that Work shall terminate as of the date such litigation 101 | is filed. 102 | 103 | 4. Redistribution. You may reproduce and distribute copies of the Work or 104 | Derivative Works thereof in any medium, with or without modifications, and 105 | in Source or Object form, provided that You meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or Derivative Works a copy 108 | of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices stating that 111 | You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works that You distribute, 114 | all copyright, patent, trademark, and attribution notices from the Source 115 | form of the Work, excluding those notices that do not pertain to any part 116 | of the Derivative Works; and 117 | 118 | (d) If the Work includes a "NOTICE" text file as part of its distribution, 119 | then any Derivative Works that You distribute must include a readable copy 120 | of the attribution notices contained within such NOTICE file, excluding those 121 | notices that do not pertain to any part of the Derivative Works, in at least 122 | one of the following places: within a NOTICE text file distributed as part 123 | of the Derivative Works; within the Source form or documentation, if provided 124 | along with the Derivative Works; or, within a display generated by the Derivative 125 | Works, if and wherever such third-party notices normally appear. The contents 126 | of the NOTICE file are for informational purposes only and do not modify the 127 | License. You may add Your own attribution notices within Derivative Works 128 | that You distribute, alongside or as an addendum to the NOTICE text from the 129 | Work, provided that such additional attribution notices cannot be construed 130 | as modifying the License. 131 | 132 | You may add Your own copyright statement to Your modifications and may provide 133 | additional or different license terms and conditions for use, reproduction, 134 | or distribution of Your modifications, or for any such Derivative Works as 135 | a whole, provided Your use, reproduction, and distribution of the Work otherwise 136 | complies with the conditions stated in this License. 137 | 138 | 5. Submission of Contributions. Unless You explicitly state otherwise, any 139 | Contribution intentionally submitted for inclusion in the Work by You to the 140 | Licensor shall be under the terms and conditions of this License, without 141 | any additional terms or conditions. Notwithstanding the above, nothing herein 142 | shall supersede or modify the terms of any separate license agreement you 143 | may have executed with Licensor regarding such Contributions. 144 | 145 | 6. Trademarks. This License does not grant permission to use the trade names, 146 | trademarks, service marks, or product names of the Licensor, except as required 147 | for reasonable and customary use in describing the origin of the Work and 148 | reproducing the content of the NOTICE file. 149 | 150 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to 151 | in writing, Licensor provides the Work (and each Contributor provides its 152 | Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 153 | KIND, either express or implied, including, without limitation, any warranties 154 | or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR 155 | A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness 156 | of using or redistributing the Work and assume any risks associated with Your 157 | exercise of permissions under this License. 158 | 159 | 8. Limitation of Liability. In no event and under no legal theory, whether 160 | in tort (including negligence), contract, or otherwise, unless required by 161 | applicable law (such as deliberate and grossly negligent acts) or agreed to 162 | in writing, shall any Contributor be liable to You for damages, including 163 | any direct, indirect, special, incidental, or consequential damages of any 164 | character arising as a result of this License or out of the use or inability 165 | to use the Work (including but not limited to damages for loss of goodwill, 166 | work stoppage, computer failure or malfunction, or any and all other commercial 167 | damages or losses), even if such Contributor has been advised of the possibility 168 | of such damages. 169 | 170 | 9. Accepting Warranty or Additional Liability. While redistributing the Work 171 | or Derivative Works thereof, You may choose to offer, and charge a fee for, 172 | acceptance of support, warranty, indemnity, or other liability obligations 173 | and/or rights consistent with this License. However, in accepting such obligations, 174 | You may act only on Your own behalf and on Your sole responsibility, not on 175 | behalf of any other Contributor, and only if You agree to indemnify, defend, 176 | and hold each Contributor harmless for any liability incurred by, or claims 177 | asserted against, such Contributor by reason of your accepting any such warranty 178 | or additional liability. END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following boilerplate 183 | notice, with the fields enclosed by brackets "[]" replaced with your own identifying 184 | information. (Don't include the brackets!) The text should be enclosed in 185 | the appropriate comment syntax for the file format. We also recommend that 186 | a file or class name and description of purpose be included on the same "printed 187 | page" as the copyright notice for easier identification within third-party 188 | archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | 194 | you may not use this file except in compliance with the License. 195 | 196 | You may obtain a copy of the License at 197 | 198 | http://www.apache.org/licenses/LICENSE-2.0 199 | 200 | Unless required by applicable law or agreed to in writing, software 201 | 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | 204 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 205 | 206 | See the License for the specific language governing permissions and 207 | 208 | limitations under the License. 209 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-4.0.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/LICENSES/CC-BY-4.0.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # WebAssembly BC6H Decoder 5 | 6 | ![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg) 7 | [![CI](https://github.com/KhronosGroup/BC6H-Decoder-WASM/workflows/CI/badge.svg?branch=main&event=push)](https://github.com/KhronosGroup/BC6H-Decoder-WASM/actions?query=workflow%3ACI) 8 | 9 | A collection of optimized WebAssembly decoders for [BC6H unsigned](https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#bptc_bc6h) GPU compressed HDR texture format. 10 | 11 | These decoders are intended to be used in environments where hardware decompression of BC6H data is not available, e.g. in CLI applications or when the [`EXT_texture_compression_bptc`](https://www.khronos.org/registry/webgl/extensions/EXT_texture_compression_bptc/) WebGL extension is unsupported. 12 | 13 | These decoders accept only low-level compressed payloads. Containers such as `.dds` or `.ktx2` ([KTX](https://github.khronos.org/KTX-Specification/)) should first be parsed by other means, then decompressed with this library. 14 | 15 | ## Build 16 | 17 | Pre-built WebAssembly binary modules (`*.wasm`) are maintained in the `build/` directory of this repository. To rebuild them from the source files, follow these steps. 18 | 19 | 1. Ensure that [Node.js](https://nodejs.org/) runtime is installed. 20 | 21 | 2. After cloning this repository, run 22 | ``` 23 | $ npm install 24 | ``` 25 | 26 | 3. After all the dependencies are fetched, run 27 | ``` 28 | $ npm run asbuild 29 | ``` 30 | 31 | 4. Built decoders will be available in the `build/` directory. 32 | 33 | ## Overview 34 | 35 | Decoders accept only raw BC6H blocks. Zstandard or zlib/deflate compression (if present) must be decoded in advance. 36 | 37 | Each 16-byte BC6H block is decoded to 64-192 bytes of uncompressed floating-point data, depending on a chosen target format. An application should choose the target format based on the runtime requirements and capabilities. Available targets include: 38 | 39 | ### Half-Precision Float (RGBA16F) 40 | 41 | * 8 bytes per pixel uncompressed floating-point RGBA format. 42 | * Alpha channel is set to `1.0` for all pixels. 43 | * Decoded data could be used in WebGL 2.0 or in WebGL 1.0 with [`OES_texture_half_float`](https://www.khronos.org/registry/webgl/extensions/OES_texture_half_float/) extension. 44 | * Decoding to this format fully preserves original BC6H precision and range (`[0.0 … 65504.0]`). 45 | * Due to high memory usage, this target format should be used only when other decode targets are not available (i.e. on WebGL 1.0) or when lossless decoding is absolutely required. 46 | 47 | ### Packed Float (R11FG11FB10F) 48 | 49 | * 4 bytes per pixel packed floating-point RGB format. 50 | * Decoded data could be used only in WebGL 2.0 contexts. 51 | * This format has slightly smaller ranges and reduced precision compared to the original BC6H data. 52 | * Due to the asymmetry of color channels, grayscale pixels may yield visible discoloration (blue/yellow) starting around `0.5`. 53 | * Three decoder modules are available with slightly different tradeoffs: 54 | - `bc6hu-r11fg11fb10f_trunc.wasm` 55 | - Fast processing at a cost of less accurate conversion. 56 | - Red and green values are clamped to `[0.0 … 65024.0]`; blue values are clamped to `[0.0 … 64512.0]`. 57 | - `bc6hu-r11fg11fb10f_round.wasm` 58 | - Accurate conversion at a cost of slower processing. 59 | - Red and green values are clamped to `[0.0 … 65024.0]`; blue values are clamped to `[0.0 … 64512.0]`. 60 | - `bc6hu-r11fg11fb10f_round_noclamp.wasm` 61 | - Faster conversion than the previous option at a cost of skipped clamping step. 62 | - Red and green values greater than `65024.0` or blue values greater than `64512.0` are mapped to positive infinity. 63 | - This is the best option when the compressed data stays within the aforementioned ranges or when the renderer is resilient to infinite values. 64 | 65 | ### Packed Shared Exponent Float (RGB9E5) 66 | 67 | * 4 bytes per pixel packed floating-point RGB format. 68 | * Decoded data could be used only in WebGL 2.0 contexts. 69 | * Original BC6H values are clamped to `[0.0 … 65408.0]`. 70 | * Due to shared exponent encoding, effective per-pixel precision depends on a channel having the maximum value. 71 | * Although this target format takes more time to decode to, it may provide better quality than R11FG11FB10F. 72 | 73 | ### Single-Precision Float (RGB32F) 74 | 75 | * 12 bytes per pixel uncompressed floating-point RGB format. 76 | * Decoding to this format fully preserves original BC6H precision and range (`[0.0 … 65504.0]`). 77 | * Although it's possible to use the decoded data in any WebGL context with [`OES_texture_float`](https://www.khronos.org/registry/webgl/extensions/OES_texture_float/) extension, this target format should only be used for CPU-side processing (e.g. via mapping the decompressed data with a [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array)) as it provides no benefits over RGBA16F on the GPU side. 78 | 79 | ## Usage 80 | 81 | 1. For a single texture, the amount of the required memory should be calculated as: 82 | ```js 83 | const xBlocks = (width + 3) >> 2; 84 | const yBlocks = (height + 3) >> 2; 85 | const compressedByteLength = xBlocks * yBlocks * 16; 86 | 87 | // RGBA16F needs 8, RGB32F needs 12. 88 | const pixelByteLength = 4; 89 | 90 | // Uncompressed texture padded to multiple-of-4 height 91 | const uncompressedByteLength = width * yBlocks * 4 * pixelByteLength; 92 | const totalByteLength = compressedByteLength + uncompressedByteLength; 93 | ``` 94 | 95 | 2. Create a [`WebAssembly.Memory`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) object large enough to contain both the compressed and the uncompressed data. Its size is given in pages, each page is 65536 bytes. The zeroth page is reserved for the decoder's internal use, so the total amount of pages should be computed as: 96 | ```js 97 | const texMemoryPages = (totalByteLength + 65535) >> 16; 98 | const memory = new WebAssembly.Memory({ initial: texMemoryPages + 1 }); 99 | ``` 100 | 101 | 3. Create a view into the memory region that will be used for transferring compressed texture data. This step must be repeated after calling [`memory.grow`]( 102 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow), such as when allocating space for another, larger, texture. 103 | 104 | ```js 105 | let compressedTextureView = new Uint8Array(memory.buffer, 65536, compressedByteLength); 106 | ``` 107 | 108 | 4. The memory could be populated with the BC6H data even before the decoder is ready. 109 | ```js 110 | compressedTextureView.set(compressedData /* Uint8Array */); 111 | ``` 112 | 113 | 5. Create a view into the memory region that will be used for transferring the decoded texture data. This step must be repeated after calling [`memory.grow`]( 114 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow), such as when allocating space for another, larger, texture. 115 | 116 | ```js 117 | const textureByteLength = width * height * pixelByteLength; 118 | let decodedTextureView = new Uint8Array(memory.buffer, 65536 + compressedByteLength, textureByteLength); 119 | ``` 120 | 121 | 6. Fetch and instantiate the decoder with the created memory. Note, that the example code uses [Fetch](https://fetch.spec.whatwg.org/) and [WebAssembly Web](https://webassembly.github.io/spec/web-api/index.html) APIs. Other JavaScript environments (such as Node.js) would need slightly different steps. 122 | ```js 123 | const decoder = ( 124 | await WebAssembly.instantiateStreaming( 125 | fetch('bc6hu-rgb9e5.wasm'), 126 | { env: { memory } } 127 | ) 128 | ).instance.exports; 129 | ``` 130 | 131 | 7. For each new texture, call the exported `decode` function passing the texture dimensions. If they are negative or exceed the available memory, the function returns `1`. Otherwise, it performs the decoding and returns `0`. The decoded texture data will be available through the `decodedTextureView` memory view. 132 | ```js 133 | compressedTextureView.set(compressedData); 134 | if (decoder.decode(width, height) === 0) { 135 | // Use decodedTextureView data 136 | } else { 137 | // Wrong dimensions 138 | } 139 | ``` 140 | 141 | 7. In a case when a new texture does not fit into the existing memory, the latter could be expanded by calling [`memory.grow`]( 142 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow). Note that the memory views would need to be recreated afterwards, by repeating step (3) and repeating step (5) in this case. 143 | -------------------------------------------------------------------------------- /assembly/decoder.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Khronos Group Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // @ts-ignore 6 | const kIsRGBA16F = MODE == 0; 7 | // @ts-ignore 8 | const kIsRGB9E5 = MODE == 1; 9 | // @ts-ignore 10 | const kIsRoundRG11FB10F = MODE == 2; 11 | // @ts-ignore 12 | const kIsTruncRG11FB10F = MODE == 3; 13 | // @ts-ignore 14 | const kIsRoundNoClampRG11FB10F = MODE == 4; 15 | // @ts-ignore 16 | const kIsRGB32F = MODE == 5; 17 | 18 | if (!kIsRGBA16F && 19 | !kIsRGB9E5 && 20 | !kIsTruncRG11FB10F && 21 | !kIsRoundRG11FB10F && 22 | !kIsRoundNoClampRG11FB10F && 23 | !kIsRGB32F) { 24 | ERROR('Decode mode is unspecified'); 25 | } 26 | 27 | const kPixelLength = kIsRGBA16F ? 8 : (kIsRGB32F ? 12 : 4); 28 | 29 | let firstRun = true; 30 | 31 | /** 32 | * Decode BC6H data as RGBA16F 33 | * @param width - Texture width in pixels 34 | * @param height - Texture height in pixels 35 | */ 36 | export function decode(width: i32, height: i32): i32 { 37 | // Fail on negative dimensions 38 | if ((width | height) < 0) return 1; 39 | 40 | const xBlocks = (width + 3) >> 2; 41 | const yBlocks = (height + 3) >> 2; 42 | 43 | // Fail on insufficient memory 44 | const compressedByteLength = xBlocks * yBlocks * 16; 45 | const decompressedByteLength = width * (4 * yBlocks) * kPixelLength; 46 | const totalMemoryLength = compressedByteLength + decompressedByteLength; 47 | if ((memory.size() - 1) * 65536 < totalMemoryLength) { 48 | return 1; 49 | } 50 | 51 | const kUserDataOffset = 65536; 52 | 53 | if (firstRun) { 54 | // 4-bit weights 55 | // [0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64] 56 | store(0, 0x1E1A15110D090400); 57 | store(8, 0x403C37332F2B2622); 58 | 59 | // 3-bit weights 60 | // [0, 9, 18, 27, 37, 46, 55, 64] 61 | store(16, 0x40372E251B120900); 62 | 63 | // Partition patterns 64 | store(32, 0xECC8EEEE8888CCCC, 0); 65 | store(32, 0xEC80FEC8FEECC880, 8); 66 | store(32, 0xE800FE80FFECC800, 16); 67 | store(32, 0xF000FFF0FF00FFE8, 24); 68 | store(32, 0x08CE7100008EF710, 32); 69 | store(32, 0x8CCE31007310008C, 40); 70 | store(32, 0x366C66663110088C, 48); 71 | store(32, 0x399C718E0FF017E8, 56); 72 | 73 | // Bit-reverse 6 bits for Mode 15 74 | store(96, 0x3818280830102000, 0); 75 | store(96, 0x3C1C2C0C34142404, 8); 76 | store(96, 0x3A1A2A0A32122202, 16); 77 | store(96, 0x3E1E2E0E36162606, 24); 78 | store(96, 0x3919290931112101, 32); 79 | store(96, 0x3D1D2D0D35152505, 40); 80 | store(96, 0x3B1B2B0B33132303, 48); 81 | store(96, 0x3F1F2F0F37172707, 56); 82 | 83 | // Precompute unquantized endpoints 84 | for (let w: u32 = 6, offset = 160; w < 13; w++) { 85 | const n: u32 = 1 << w; 86 | const lo: u32 = 1 << (15 - w); 87 | const hi: u32 = (((1 << w) - 1) << (16 - w)) | lo; 88 | for (let i: u32 = 0; i < n; i++) { 89 | let value: u32 = i << (16 - w); 90 | value |= value ? lo : 0; 91 | value = (value == hi) ? 65535 : value; 92 | store(offset + i * 2, value); 93 | } 94 | offset += n * 2; 95 | } 96 | 97 | firstRun = false; 98 | } 99 | 100 | const completeXBlocks = width >> 2; 101 | const extraByteLength = (width & 3) * kPixelLength; 102 | const uncompressedLineByteStride = width * kPixelLength; 103 | const writeSkip = uncompressedLineByteStride * 3 + extraByteLength; 104 | 105 | const compressedBlockSkip = extraByteLength ? 16 : 0; 106 | 107 | let readOffset = kUserDataOffset; 108 | let writeOffset = readOffset + compressedByteLength; 109 | 110 | for (let y = 0; y < yBlocks; y++) { 111 | for (let x = 0; x < completeXBlocks; x++) { 112 | decodeBlock(readOffset, writeOffset, uncompressedLineByteStride); 113 | readOffset += 16; 114 | writeOffset += 4 * kPixelLength; 115 | } 116 | readOffset += compressedBlockSkip; 117 | writeOffset += writeSkip; 118 | } 119 | 120 | // Image width is not a multiple of 4. 121 | if (extraByteLength) { 122 | readOffset = kUserDataOffset + completeXBlocks * 16; 123 | writeOffset = kUserDataOffset + compressedByteLength + 124 | completeXBlocks * 4 * kPixelLength; 125 | 126 | const compressedBlockLineByteStride = xBlocks * 16; 127 | const uncompressedBlockLineByteStride = uncompressedLineByteStride * 4; 128 | 129 | for (let y = 0; y < yBlocks; y++) { 130 | const kOffset = 32768; 131 | // Decode to a temporary memory location and copy only needed pixels. 132 | decodeBlock(readOffset, kOffset, kPixelLength * 4); 133 | for (let x = 0; x < extraByteLength; x += kPixelLength) { 134 | let s = writeOffset; 135 | if (kPixelLength == 8) { 136 | store(s + x, load(x, kOffset)); 137 | s += uncompressedLineByteStride; 138 | store(s + x, load(x, kOffset + kPixelLength * 4)); 139 | s += uncompressedLineByteStride; 140 | store(s + x, load(x, kOffset + kPixelLength * 8)); 141 | s += uncompressedLineByteStride; 142 | store(s + x, load(x, kOffset + kPixelLength * 12)); 143 | } else if (kPixelLength == 4) { 144 | store(s + x, load(x, kOffset)); 145 | s += uncompressedLineByteStride; 146 | store(s + x, load(x, kOffset + kPixelLength * 4)); 147 | s += uncompressedLineByteStride; 148 | store(s + x, load(x, kOffset + kPixelLength * 8)); 149 | s += uncompressedLineByteStride; 150 | store(s + x, load(x, kOffset + kPixelLength * 12)); 151 | } else if (kPixelLength == 12) { 152 | store(s + x, load(x, kOffset)); 153 | store(s + x, load(x, kOffset + 4), 4); 154 | store(s + x, load(x, kOffset + 8), 8); 155 | s += uncompressedLineByteStride; 156 | store(s + x, load(x, kOffset + kPixelLength * 4)); 157 | store(s + x, load(x, kOffset + kPixelLength * 4 + 4), 4); 158 | store(s + x, load(x, kOffset + kPixelLength * 4 + 8), 8); 159 | s += uncompressedLineByteStride; 160 | store(s + x, load(x, kOffset + kPixelLength * 8)); 161 | store(s + x, load(x, kOffset + kPixelLength * 8 + 4), 4); 162 | store(s + x, load(x, kOffset + kPixelLength * 8 + 8), 8); 163 | s += uncompressedLineByteStride; 164 | store(s + x, load(x, kOffset + kPixelLength * 12)); 165 | store(s + x, load(x, kOffset + kPixelLength * 12 + 4), 4); 166 | store(s + x, load(x, kOffset + kPixelLength * 12 + 8), 8); 167 | } else { 168 | ERROR('Invalid kPixelLength.'); 169 | } 170 | } 171 | readOffset += compressedBlockLineByteStride; 172 | writeOffset += uncompressedBlockLineByteStride; 173 | } 174 | } 175 | return 0; 176 | } 177 | 178 | function decodeBlock(readOffset: i32, offset: i32, stride: i32): void { 179 | const q0 = load(readOffset, 0); 180 | const q1 = load(readOffset, 8); 181 | 182 | if (3 == (q0 & 3)) { 183 | decodeOneSubsetBlock(q0, q1, offset, stride); 184 | } else { 185 | decodeTwoSubsetBlock(q0, q1, offset, stride); 186 | } 187 | } 188 | 189 | // @ts-ignore 190 | @inline 191 | function decodeOneSubsetBlock(q0: u64, q1: u64, offset: i32, stride: i32): void { 192 | // One-subset modes always use lower 5 bits 193 | const mode = q0 & 0x1F; 194 | 195 | // 32-bit views into 64-bit inputs 196 | const d0 = q0; 197 | const d1 = (q0 >> 32); 198 | const d2 = q1; 199 | 200 | let r0: u32 = 0; 201 | let g0: u32 = 0; 202 | let b0: u32 = 0; 203 | 204 | let r1: u32 = 0; 205 | let g1: u32 = 0; 206 | let b1: u32 = 0; 207 | 208 | switch (mode) { 209 | case 3: 210 | // rgb0 - 10 bits 211 | // rgb1 - 10 bits 212 | 213 | r0 = (d0 >> 5) & 0x3FF; 214 | g0 = (d0 >> 15) & 0x3FF; 215 | b0 = ((q0 >> 25) & 0x3FF); 216 | 217 | r1 = (d1 >> 3) & 0x3FF; 218 | g1 = (d1 >> 13) & 0x3FF; 219 | b1 = ((d2 << 9) & 0x200) | (d1 >> 23); 220 | 221 | r0 = unq(10, r0); 222 | g0 = unq(10, g0); 223 | b0 = unq(10, b0); 224 | 225 | r1 = unq(10, r1); 226 | g1 = unq(10, g1); 227 | b1 = unq(10, b1); 228 | break; 229 | case 7: 230 | // rgb0 - 11 bits 231 | // rgb1 - 9 bits (delta) 232 | 233 | r0 = ((d1 >> 2) & 0x400) | ((d0 >> 5) & 0x3FF); 234 | g0 = ((d1 >> 12) & 0x400) | ((d0 >> 15) & 0x3FF); 235 | b0 = ((d2 << 10) & 0x400) | ((q0 >> 25) & 0x3FF); 236 | 237 | r1 = (r0 + signExtend(9, d1 >> 3)) & 0x7FF; 238 | g1 = (g0 + signExtend(9, d1 >> 13)) & 0x7FF; 239 | b1 = (b0 + signExtend(9, d1 >> 23)) & 0x7FF; 240 | 241 | r0 = unq(11, r0); 242 | g0 = unq(11, g0); 243 | b0 = unq(11, b0); 244 | 245 | r1 = unq(11, r1); 246 | g1 = unq(11, g1); 247 | b1 = unq(11, b1); 248 | break; 249 | case 11: 250 | // rgb0 - 12 bits 251 | // rgb1 - 8 bits (delta) 252 | 253 | r0 = ( 254 | ((d1) & 0x800) | 255 | ((d1 >> 2) & 0x400) | 256 | ((d0 >> 5) & 0x3FF) 257 | ); 258 | g0 = ( 259 | ((d1 >> 10) & 0x800) | 260 | ((d1 >> 12) & 0x400) | 261 | ((d0 >> 15) & 0x3FF) 262 | ); 263 | b0 = ( 264 | ((d1 >> 20) & 0x800) | 265 | ((d2 << 10) & 0x400) | 266 | ((q0 >> 25) & 0x3FF) 267 | ); 268 | 269 | r1 = (r0 + signExtend(8, d1 >> 3)) & 0xFFF; 270 | g1 = (g0 + signExtend(8, d1 >> 13)) & 0xFFF; 271 | b1 = (b0 + signExtend(8, d1 >> 23)) & 0xFFF; 272 | 273 | r0 = unq(12, r0); 274 | g0 = unq(12, g0); 275 | b0 = unq(12, b0); 276 | 277 | r1 = unq(12, r1); 278 | g1 = unq(12, g1); 279 | b1 = unq(12, b1); 280 | break; 281 | case 15: 282 | // rgb0 - 16 bits 283 | // rgb1 - 4 bits (delta) 284 | 285 | r0 = ( 286 | (reverse6((d1 >> 7) & 0x3F) << 10) | 287 | ((d0 >> 5) & 0x3FF) 288 | ); 289 | g0 = ( 290 | (reverse6((d1 >> 17) & 0x3F) << 10) | 291 | ((d0 >> 15) & 0x3FF) 292 | ); 293 | b0 = ( 294 | ((reverse6(d1 >> 27) | (d2 & 1)) << 10) | 295 | ((q0 >> 25) & 0x3FF) 296 | ); 297 | 298 | r1 = (r0 + signExtend(4, d1 >> 3)) & 0xFFFF; 299 | g1 = (g0 + signExtend(4, d1 >> 13)) & 0xFFFF; 300 | b1 = (b0 + signExtend(4, d1 >> 23)) & 0xFFFF; 301 | 302 | // No need to unquantize 16-bit endpoints 303 | break; 304 | } 305 | 306 | let weights = (q1 & 0xFFFFFFFFFFFFFFF0) | ((q1 >> 1) & 7); 307 | 308 | const rs0 = r0 * 64 + 32; 309 | const gs0 = g0 * 64 + 32; 310 | const bs0 = b0 * 64 + 32; 311 | const rd0 = r1 - r0; 312 | const gd0 = g1 - g0; 313 | const bd0 = b1 - b0; 314 | 315 | for (let i = 0; i < 4; i++) { 316 | if (kIsRGBA16F) { 317 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 318 | weights & 0xF)); 319 | } else if (kIsRGB32F) { 320 | const w = weight4(weights & 0xF); 321 | store(offset, lerpF32(rs0, rd0, w)); 322 | store(offset, lerpF32(gs0, gd0, w), 4); 323 | store(offset, lerpF32(bs0, bd0, w), 8); 324 | } else { 325 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 326 | weights & 0xF)); 327 | } 328 | weights >>= 4; 329 | 330 | if (kIsRGBA16F) { 331 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 332 | weights & 0xF), kPixelLength); 333 | } else if (kIsRGB32F) { 334 | const w = weight4(weights & 0xF); 335 | store(offset, lerpF32(rs0, rd0, w), kPixelLength); 336 | store(offset, lerpF32(gs0, gd0, w), kPixelLength + 4); 337 | store(offset, lerpF32(bs0, bd0, w), kPixelLength + 8); 338 | } else { 339 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 340 | weights & 0xF), kPixelLength); 341 | } 342 | weights >>= 4; 343 | 344 | if (kIsRGBA16F) { 345 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 346 | weights & 0xF), kPixelLength * 2); 347 | } else if (kIsRGB32F) { 348 | const w = weight4(weights & 0xF); 349 | store(offset, lerpF32(rs0, rd0, w), kPixelLength * 2); 350 | store(offset, lerpF32(gs0, gd0, w), kPixelLength * 2 + 4); 351 | store(offset, lerpF32(bs0, bd0, w), kPixelLength * 2 + 8); 352 | } else { 353 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 354 | weights & 0xF), kPixelLength * 2); 355 | } 356 | weights >>= 4; 357 | 358 | if (kIsRGBA16F) { 359 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 360 | weights & 0xF), kPixelLength * 3); 361 | } else if (kIsRGB32F) { 362 | const w = weight4(weights & 0xF); 363 | store(offset, lerpF32(rs0, rd0, w), kPixelLength * 3); 364 | store(offset, lerpF32(gs0, gd0, w), kPixelLength * 3 + 4); 365 | store(offset, lerpF32(bs0, bd0, w), kPixelLength * 3 + 8); 366 | } else { 367 | store(offset, lerp1(rs0, gs0, bs0, rd0, gd0, bd0, 368 | weights & 0xF), kPixelLength * 3); 369 | } 370 | weights >>= 4; 371 | offset += stride; 372 | } 373 | } 374 | 375 | // @ts-ignore 376 | @inline 377 | function decodeTwoSubsetBlock(q0: u64, q1: u64, offset: i32, stride: i32): void { 378 | const mode = q0 & ((q0 & 2) ? 0x1F : 3); 379 | 380 | // 32-bit views into 64-bit inputs 381 | const d0 = q0; 382 | const d1 = (q0 >> 32); 383 | const d2 = q1; 384 | 385 | let r0: u32 = 0; 386 | let g0: u32 = 0; 387 | let b0: u32 = 0; 388 | 389 | let r1: u32 = 0; 390 | let g1: u32 = 0; 391 | let b1: u32 = 0; 392 | 393 | let r2: u32 = 0; 394 | let g2: u32 = 0; 395 | let b2: u32 = 0; 396 | 397 | let r3: u32 = 0; 398 | let g3: u32 = 0; 399 | let b3: u32 = 0; 400 | 401 | switch (mode) { 402 | case 0: 403 | // rgb0 - 10 bits 404 | // rgb1, rgb2, rgb3 - 5 bits (delta) 405 | 406 | r0 = (d0 >> 5) & 0x3FF; 407 | g0 = (d0 >> 15) & 0x3FF; 408 | b0 = ((q0 >> 25) & 0x3FF); 409 | 410 | r1 = r0 + signExtend(5, d1 >> 3); 411 | g1 = g0 + signExtend(5, d1 >> 13); 412 | b1 = b0 + signExtend(5, d1 >> 23); 413 | 414 | r2 = r0 + signExtend(5, d2 >> 1); 415 | g2 = g0 + signExtend(5, ((d0 << 2) & 0x10) | ((d1 >> 9) & 0xF)); 416 | b2 = b0 + signExtend(5, ( 417 | ((d0 << 1) & 0x10) | 418 | ((d2 << 3) & 0x08) | 419 | ((d1 >> 29)) 420 | )); 421 | 422 | r3 = r0 + signExtend(5, d2 >> 7); 423 | g3 = g0 + signExtend(5, ((d1 >> 4) & 0x10) | ((d1 >> 19) & 0xF)); 424 | b3 = b0 + signExtend(5, ( 425 | ((d0 ) & 0x10) | 426 | ((d2 >> 9) & 0x08) | 427 | ((d2 >> 4) & 0x04) | 428 | ((d1 >> 27) & 0x02) | 429 | ((d1 >> 18) & 0x01) 430 | )); 431 | 432 | r0 = unq(10, r0); 433 | g0 = unq(10, g0); 434 | b0 = unq(10, b0); 435 | 436 | r1 = unq(10, r1 & 0x3FF); 437 | g1 = unq(10, g1 & 0x3FF); 438 | b1 = unq(10, b1 & 0x3FF); 439 | 440 | r2 = unq(10, r2 & 0x3FF); 441 | g2 = unq(10, g2 & 0x3FF); 442 | b2 = unq(10, b2 & 0x3FF); 443 | 444 | r3 = unq(10, r3 & 0x3FF); 445 | g3 = unq(10, g3 & 0x3FF); 446 | b3 = unq(10, b3 & 0x3FF); 447 | break; 448 | case 1: 449 | // rgb0 - 7 bits 450 | // rgb1, rgb2, rgb3 - 6 bits (delta) 451 | 452 | r0 = (d0 >> 5) & 0x7F; 453 | g0 = (d0 >> 15) & 0x7F; 454 | b0 = (d0 >> 25); 455 | 456 | r1 = r0 + signExtend(6, d1 >> 3); 457 | g1 = g0 + signExtend(6, d1 >> 13); 458 | b1 = b0 + signExtend(6, d1 >> 23); 459 | 460 | r2 = r0 + signExtend(6, d2 >> 1); 461 | g2 = g0 + signExtend(6, ( 462 | ((d0 << 3) & 0x20) | 463 | ((d0 >> 20) & 0x10) | 464 | ((d1 >> 9) & 0x0F) 465 | )); 466 | b2 = b0 + signExtend(6, ( 467 | ((d0 >> 17) & 0x20) | 468 | ((d0 >> 10) & 0x10) | 469 | ((d2 << 3) & 0x08) | 470 | ((d1 >> 29)) 471 | )); 472 | 473 | r3 = r0 + signExtend(6, d2 >> 7); 474 | g3 = g0 + signExtend(6, ((d0 << 1) & 0x30) | ((d1 >> 19) & 0xF)); 475 | b3 = b0 + signExtend(6, ( 476 | ((d1 << 4) & 0x20) | 477 | ((d1 << 2) & 0x10) | 478 | ((d1 << 3) & 0x08) | 479 | ((d0 >> 21) & 0x04) | 480 | ((d0 >> 12) & 0x03) 481 | )); 482 | 483 | r0 = unq(7, r0); 484 | g0 = unq(7, g0); 485 | b0 = unq(7, b0); 486 | 487 | r1 = unq(7, r1 & 0x7F); 488 | g1 = unq(7, g1 & 0x7F); 489 | b1 = unq(7, b1 & 0x7F); 490 | 491 | r2 = unq(7, r2 & 0x7F); 492 | g2 = unq(7, g2 & 0x7F); 493 | b2 = unq(7, b2 & 0x7F); 494 | 495 | r3 = unq(7, r3 & 0x7F); 496 | g3 = unq(7, g3 & 0x7F); 497 | b3 = unq(7, b3 & 0x7F); 498 | break; 499 | case 2: 500 | // rgb0 - 11 bits 501 | // r1, r2, r3 - 5 bits (delta) 502 | // g1, g2, g3 - 4 bits (delta) 503 | // b1, b2, b3 - 4 bits (delta) 504 | 505 | r0 = ((d1 << 2) & 0x400) | ((d0 >> 5) & 0x3FF); 506 | g0 = ((d1 >> 7) & 0x400) | ((d0 >> 15) & 0x3FF); 507 | b0 = ((d1 >> 17) & 0x400) | ((q0 >> 25) & 0x3FF); 508 | 509 | r1 = r0 + signExtend(5, d1 >> 3); 510 | g1 = g0 + signExtend(4, d1 >> 13); 511 | b1 = b0 + signExtend(4, d1 >> 23); 512 | 513 | r2 = r0 + signExtend(5, d2 >> 1); 514 | g2 = g0 + signExtend(4, d1 >> 9); 515 | b2 = b0 + signExtend(4, ((d2 << 3) & 8) | (d1 >> 29)); 516 | 517 | r3 = r0 + signExtend(5, d2 >> 7); 518 | g3 = g0 + signExtend(4, d1 >> 19); 519 | b3 = b0 + signExtend(4, ( 520 | ((d2 >> 9) & 8) | 521 | ((d2 >> 4) & 4) | 522 | ((d1 >> 27) & 2) | 523 | ((d1 >> 18) & 1) 524 | )); 525 | 526 | r0 = unq(11, r0); 527 | g0 = unq(11, g0); 528 | b0 = unq(11, b0); 529 | 530 | r1 = unq(11, r1 & 0x7FF); 531 | g1 = unq(11, g1 & 0x7FF); 532 | b1 = unq(11, b1 & 0x7FF); 533 | 534 | r2 = unq(11, r2 & 0x7FF); 535 | g2 = unq(11, g2 & 0x7FF); 536 | b2 = unq(11, b2 & 0x7FF); 537 | 538 | r3 = unq(11, r3 & 0x7FF); 539 | g3 = unq(11, g3 & 0x7FF); 540 | b3 = unq(11, b3 & 0x7FF); 541 | break; 542 | case 6: 543 | // rgb0 - 11 bits 544 | // r1, r2, r3 - 4 bits (delta) 545 | // g1, g2, g3 - 5 bits (delta) 546 | // b1, b2, b3 - 4 bits (delta) 547 | 548 | r0 = (((q0 >> 29) & 0x400) | ((q0 >> 5) & 0x3FF)); 549 | g0 = (((q0 >> 40) & 0x400) | ((q0 >> 15) & 0x3FF)); 550 | b0 = (((q0 >> 49) & 0x400) | ((q0 >> 25) & 0x3FF)); 551 | 552 | r1 = r0 + signExtend(4, d1 >> 3); 553 | g1 = g0 + signExtend(5, d1 >> 13); 554 | b1 = b0 + signExtend(4, d1 >> 23); 555 | 556 | r2 = r0 + signExtend(4, d2 >> 1); 557 | g2 = g0 + signExtend(5, ((d2 >> 7) & 0x10) | ((d1 >> 9) & 0x0F)); 558 | b2 = b0 + signExtend(4, ((d2 << 3) & 0x08) | ((d1 >> 29))); 559 | 560 | r3 = r0 + signExtend(4, d2 >> 7); 561 | g3 = g0 + signExtend(5, ((d1 >> 4) & 0x10) | ((d1 >> 19) & 0x0F)); 562 | b3 = b0 + signExtend(4, ( 563 | ((d2 >> 9) & 8) | 564 | ((d2 >> 4) & 4) | 565 | ((d1 >> 27) & 2) | 566 | ((d2 >> 5) & 1) 567 | )); 568 | 569 | r0 = unq(11, r0); 570 | g0 = unq(11, g0); 571 | b0 = unq(11, b0); 572 | 573 | r1 = unq(11, r1 & 0x7FF); 574 | g1 = unq(11, g1 & 0x7FF); 575 | b1 = unq(11, b1 & 0x7FF); 576 | 577 | r2 = unq(11, r2 & 0x7FF); 578 | g2 = unq(11, g2 & 0x7FF); 579 | b2 = unq(11, b2 & 0x7FF); 580 | 581 | r3 = unq(11, r3 & 0x7FF); 582 | g3 = unq(11, g3 & 0x7FF); 583 | b3 = unq(11, b3 & 0x7FF); 584 | break; 585 | case 10: 586 | // rgb0 - 11 bits 587 | // r1, r2, r3 - 4 bits (delta) 588 | // g1, g2, g3 - 4 bits (delta) 589 | // b1, b2, b3 - 5 bits (delta) 590 | 591 | r0 = ((d1 << 3) & 0x400) | ((d0 >> 5) & 0x3FF); 592 | g0 = ((d1 >> 7) & 0x400) | ((d0 >> 15) & 0x3FF); 593 | b0 = ((d1 >> 18) & 0x400) | ((q0 >> 25) & 0x3FF); 594 | 595 | r1 = r0 + signExtend(4, d1 >> 3); 596 | g1 = g0 + signExtend(4, d1 >> 13); 597 | b1 = b0 + signExtend(5, d1 >> 23); 598 | 599 | r2 = r0 + signExtend(4, d2 >> 1); 600 | g2 = g0 + signExtend(4, d1 >> 9); 601 | b2 = b0 + signExtend(5, ((d1 >> 4) & 0x10) | ((d2 << 3) & 8) | (d1 >> 29)); 602 | 603 | r3 = r0 + signExtend(4, d2 >> 7); 604 | g3 = g0 + signExtend(4, d1 >> 19); 605 | b3 = b0 + signExtend(5, ( 606 | ((d2 >> 7) & 0x10) | 607 | ((d2 >> 9) & 0x08) | 608 | ((d2 >> 4) & 0x06) | 609 | ((d1 >> 18) & 0x01) 610 | )); 611 | 612 | r0 = unq(11, r0); 613 | g0 = unq(11, g0); 614 | b0 = unq(11, b0); 615 | 616 | r1 = unq(11, r1 & 0x7FF); 617 | g1 = unq(11, g1 & 0x7FF); 618 | b1 = unq(11, b1 & 0x7FF); 619 | 620 | r2 = unq(11, r2 & 0x7FF); 621 | g2 = unq(11, g2 & 0x7FF); 622 | b2 = unq(11, b2 & 0x7FF); 623 | 624 | r3 = unq(11, r3 & 0x7FF); 625 | g3 = unq(11, g3 & 0x7FF); 626 | b3 = unq(11, b3 & 0x7FF); 627 | break; 628 | case 14: 629 | // rgb0 - 9 bits 630 | // rgb1, rgb2, rgb3 - 5 bits (delta) 631 | 632 | r0 = (d0 >> 5) & 0x1FF; 633 | g0 = (d0 >> 15) & 0x1FF; 634 | b0 = ((q0 >> 25) & 0x1FF); 635 | 636 | r1 = r0 + signExtend(5, d1 >> 3); 637 | g1 = g0 + signExtend(5, d1 >> 13); 638 | b1 = b0 + signExtend(5, d1 >> 23); 639 | 640 | r2 = r0 + signExtend(5, d2 >> 1); 641 | g2 = g0 + signExtend(5, ((d0 >> 20) & 0x10) | ((d1 >> 9) & 0xF)); 642 | b2 = b0 + signExtend(5, ((d0 >> 10) & 0x10) | ((d2 << 3) & 8) | (d1 >> 29)); 643 | 644 | r3 = r0 + signExtend(5, d2 >> 7); 645 | g3 = g0 + signExtend(5, ((d1 >> 4) & 0x10) | ((d1 >> 19) & 0xF)); 646 | b3 = b0 + signExtend(5, ( 647 | ((d1 << 2) & 0x10) | 648 | ((d2 >> 9) & 0x08) | 649 | ((d2 >> 4) & 0x04) | 650 | ((d1 >> 27) & 0x02) | 651 | ((d1 >> 18) & 0x01) 652 | )); 653 | 654 | r0 = unq(9, r0); 655 | g0 = unq(9, g0); 656 | b0 = unq(9, b0); 657 | 658 | r1 = unq(9, r1 & 0x1FF); 659 | g1 = unq(9, g1 & 0x1FF); 660 | b1 = unq(9, b1 & 0x1FF); 661 | 662 | r2 = unq(9, r2 & 0x1FF); 663 | g2 = unq(9, g2 & 0x1FF); 664 | b2 = unq(9, b2 & 0x1FF); 665 | 666 | r3 = unq(9, r3 & 0x1FF); 667 | g3 = unq(9, g3 & 0x1FF); 668 | b3 = unq(9, b3 & 0x1FF); 669 | break; 670 | case 18: 671 | // rgb0 - 8 bits 672 | // r1, r2, r3 - 6 bits (delta) 673 | // g1, g2, g3 - 5 bits (delta) 674 | // b1, b2, b3 - 5 bits (delta) 675 | 676 | r0 = (d0 >> 5) & 0xFF; 677 | g0 = (d0 >> 15) & 0xFF; 678 | b0 = ((q0 >> 25) & 0xFF); 679 | 680 | r1 = r0 + signExtend(6, d1 >> 3); 681 | g1 = g0 + signExtend(5, d1 >> 13); 682 | b1 = b0 + signExtend(5, d1 >> 23); 683 | 684 | r2 = r0 + signExtend(6, d2 >> 1); 685 | g2 = g0 + signExtend(5, ((d0 >> 20) & 0x10) | ((d1 >> 9) & 0xF)); 686 | b2 = b0 + signExtend(5, ((d0 >> 10) & 0x10) | ((d2 << 3) & 8) | (d1 >> 29)); 687 | 688 | r3 = r0 + signExtend(6, d2 >> 7); 689 | g3 = g0 + signExtend(5, ((d0 >> 9) & 0x10) | ((d1 >> 19) & 0xF)); 690 | b3 = b0 + signExtend(5, ( 691 | ((d1 << 2) & 0x18) | 692 | ((d0 >> 21) & 0x04) | 693 | ((d1 >> 27) & 0x02) | 694 | ((d1 >> 18) & 0x01) 695 | )); 696 | 697 | r0 = unq(8, r0); 698 | g0 = unq(8, g0); 699 | b0 = unq(8, b0); 700 | 701 | r1 = unq(8, r1 & 0xFF); 702 | g1 = unq(8, g1 & 0xFF); 703 | b1 = unq(8, b1 & 0xFF); 704 | 705 | r2 = unq(8, r2 & 0xFF); 706 | g2 = unq(8, g2 & 0xFF); 707 | b2 = unq(8, b2 & 0xFF); 708 | 709 | r3 = unq(8, r3 & 0xFF); 710 | g3 = unq(8, g3 & 0xFF); 711 | b3 = unq(8, b3 & 0xFF); 712 | break; 713 | case 22: 714 | // rgb0 - 8 bits 715 | // r1, r2, r3 - 5 bits (delta) 716 | // g1, g2, g3 - 6 bits (delta) 717 | // b1, b2, b3 - 5 bits (delta) 718 | 719 | r0 = (d0 >> 5) & 0xFF; 720 | g0 = (d0 >> 15) & 0xFF; 721 | b0 = ((q0 >> 25) & 0xFF); 722 | 723 | r1 = r0 + signExtend(5, d1 >> 3); 724 | g1 = g0 + signExtend(6, d1 >> 13); 725 | b1 = b0 + signExtend(5, d1 >> 23); 726 | 727 | r2 = r0 + signExtend(5, d2 >> 1); 728 | g2 = g0 + signExtend(6, ( 729 | ((d0 >> 18) & 0x20) | 730 | ((d0 >> 20) & 0x10) | 731 | ((d1 >> 9) & 0xF) 732 | )); 733 | b2 = b0 + signExtend(5, ( 734 | ((d0 >> 10) & 0x10) | 735 | ((d2 << 3) & 0x08) | 736 | ((d1 >> 29)) 737 | )); 738 | 739 | r3 = r0 + signExtend(5, d2 >> 7); 740 | g3 = g0 + signExtend(6, ( 741 | ((d1 << 4) & 0x20) | 742 | ((d1 >> 4) & 0x10) | 743 | ((d1 >> 19) & 0x0F) 744 | )); 745 | b3 = b0 + signExtend(5, ( 746 | ((d1 << 2) & 0x10) | 747 | ((d2 >> 9) & 0x08) | 748 | ((d2 >> 4) & 0x04) | 749 | ((d1 >> 27) & 0x02) | 750 | ((d0 >> 13) & 0x01) 751 | )); 752 | 753 | r0 = unq(8, r0); 754 | g0 = unq(8, g0); 755 | b0 = unq(8, b0); 756 | 757 | r1 = unq(8, r1 & 0xFF); 758 | g1 = unq(8, g1 & 0xFF); 759 | b1 = unq(8, b1 & 0xFF); 760 | 761 | r2 = unq(8, r2 & 0xFF); 762 | g2 = unq(8, g2 & 0xFF); 763 | b2 = unq(8, b2 & 0xFF); 764 | 765 | r3 = unq(8, r3 & 0xFF); 766 | g3 = unq(8, g3 & 0xFF); 767 | b3 = unq(8, b3 & 0xFF); 768 | break; 769 | case 26: 770 | // rgb0 - 8 bits 771 | // r1, r2, r3 - 5 bits (delta) 772 | // g1, g2, g3 - 5 bits (delta) 773 | // b1, b2, b3 - 6 bits (delta) 774 | 775 | r0 = (d0 >> 5) & 0xFF; 776 | g0 = (d0 >> 15) & 0xFF; 777 | b0 = ((q0 >> 25) & 0xFF); 778 | 779 | r1 = r0 + signExtend(5, d1 >> 3); 780 | g1 = g0 + signExtend(5, d1 >> 13); 781 | b1 = b0 + signExtend(6, d1 >> 23); 782 | 783 | r2 = r0 + signExtend(5, d2 >> 1); 784 | g2 = g0 + signExtend(5, ((d0 >> 20) & 0x10) | ((d1 >> 9) & 0xF)); 785 | b2 = b0 + signExtend(6, ( 786 | ((d0 >> 18) & 0x20) | 787 | ((d0 >> 10) & 0x10) | 788 | ((d2 << 3) & 0x08) | 789 | ((d1 >> 29)) 790 | )); 791 | 792 | r3 = r0 + signExtend(5, d2 >> 7); 793 | g3 = g0 + signExtend(5, ((d1 >> 4) & 0x10) | ((d1 >> 19) & 0xF)); 794 | b3 = b0 + signExtend(6, ( 795 | ((d1 << 4) & 0x20) | 796 | ((d1 << 2) & 0x10) | 797 | ((d2 >> 9) & 0x08) | 798 | ((d2 >> 4) & 0x04) | 799 | ((d0 >> 12) & 0x02) | 800 | ((d1 >> 18) & 0x01) 801 | )); 802 | 803 | r0 = unq(8, r0); 804 | g0 = unq(8, g0); 805 | b0 = unq(8, b0); 806 | 807 | r1 = unq(8, r1 & 0xFF); 808 | g1 = unq(8, g1 & 0xFF); 809 | b1 = unq(8, b1 & 0xFF); 810 | 811 | r2 = unq(8, r2 & 0xFF); 812 | g2 = unq(8, g2 & 0xFF); 813 | b2 = unq(8, b2 & 0xFF); 814 | 815 | r3 = unq(8, r3 & 0xFF); 816 | g3 = unq(8, g3 & 0xFF); 817 | b3 = unq(8, b3 & 0xFF); 818 | break; 819 | case 30: 820 | // rgb0 - 6 bits 821 | // rgb1 - 6 bits 822 | // rgb2 - 6 bits 823 | // rgb3 - 6 bits 824 | 825 | r0 = (d0 >> 5) & 0x3F; 826 | g0 = (d0 >> 15) & 0x3F; 827 | b0 = (d0 >> 25) & 0x3F; 828 | 829 | r1 = (d1 >> 3) & 0x3F; 830 | g1 = (d1 >> 13) & 0x3F; 831 | b1 = (d1 >> 23) & 0x3F; 832 | 833 | r2 = (d2 >> 1) & 0x3F; 834 | g2 = ((d0 >> 16) & 0x20) | ((d0 >> 20) & 0x10) | ((d1 >> 9) & 0xF); 835 | b2 = ( 836 | ((d0 >> 17) & 0x20) | 837 | ((d0 >> 10) & 0x10) | 838 | ((d2 << 3) & 0x08) | 839 | ((d1 >> 29)) 840 | ); 841 | 842 | r3 = (d2 >> 7) & 0x3F; 843 | g3 = ((d0 >> 26) & 0x20) | ((d0 >> 7) & 0x10) | ((d1 >> 19) & 0xF); 844 | b3 = ( 845 | ((d1 << 4) & 0x20) | 846 | ((d1 << 2) & 0x10) | 847 | ((d1 << 3) & 0x08) | 848 | ((d0 >> 21) & 0x04) | 849 | ((d0 >> 12) & 0x03) 850 | ); 851 | 852 | r0 = unq(6, r0); 853 | g0 = unq(6, g0); 854 | b0 = unq(6, b0); 855 | 856 | r1 = unq(6, r1); 857 | g1 = unq(6, g1); 858 | b1 = unq(6, b1); 859 | 860 | r2 = unq(6, r2); 861 | g2 = unq(6, g2); 862 | b2 = unq(6, b2); 863 | 864 | r3 = unq(6, r3); 865 | g3 = unq(6, g3); 866 | b3 = unq(6, b3); 867 | break; 868 | } 869 | 870 | const patternIndex = (q1 >> 13) & 0x1F; 871 | 872 | const anchor = getAnchor(patternIndex) * 3; 873 | const hiMask = 0xFFFFFFFFFFFFFFFF << (anchor + 3); 874 | const loMask = (0xFFFFFFFFFFFFFFFF >> (65 - anchor)) << 3; 875 | let weights = ((q1 >> 16) & hiMask) | ((q1 >> 17) & loMask) | ((q1 >> 18) & 3); 876 | 877 | const rs0 = r0 * 64 + 32; 878 | const gs0 = g0 * 64 + 32; 879 | const bs0 = b0 * 64 + 32; 880 | const rs1 = r2 * 64 + 32; 881 | const gs1 = g2 * 64 + 32; 882 | const bs1 = b2 * 64 + 32; 883 | const rd0 = r1 - r0; 884 | const gd0 = g1 - g0; 885 | const bd0 = b1 - b0; 886 | const rd1 = r3 - r2; 887 | const gd1 = g3 - g2; 888 | const bd1 = b3 - b2; 889 | 890 | let pat = pattern(patternIndex); 891 | 892 | for (let i = 0; i < 4; i++) { 893 | if (kIsRGBA16F) { 894 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 895 | rd0, rd1, gd0, gd1, bd0, bd1, 896 | pat & 1, (weights & 7))); 897 | } else if (kIsRGB32F) { 898 | const w = weight3(weights & 7); 899 | if (pat & 1) { 900 | store(offset, lerpF32(rs1, rd1, w), 0); 901 | store(offset, lerpF32(gs1, gd1, w), 4); 902 | store(offset, lerpF32(bs1, bd1, w), 8); 903 | } else { 904 | store(offset, lerpF32(rs0, rd0, w), 0); 905 | store(offset, lerpF32(gs0, gd0, w), 4); 906 | store(offset, lerpF32(bs0, bd0, w), 8); 907 | } 908 | } else { 909 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 910 | rd0, rd1, gd0, gd1, bd0, bd1, 911 | pat & 1, (weights & 7))); 912 | } 913 | weights >>= 3; 914 | pat >>= 1; 915 | 916 | if (kIsRGBA16F) { 917 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 918 | rd0, rd1, gd0, gd1, bd0, bd1, 919 | pat & 1, (weights & 7)), 920 | kPixelLength); 921 | } else if (kIsRGB32F) { 922 | const w = weight3(weights & 7); 923 | if (pat & 1) { 924 | store(offset, lerpF32(rs1, rd1, w), kPixelLength + 0); 925 | store(offset, lerpF32(gs1, gd1, w), kPixelLength + 4); 926 | store(offset, lerpF32(bs1, bd1, w), kPixelLength + 8); 927 | } else { 928 | store(offset, lerpF32(rs0, rd0, w), kPixelLength + 0); 929 | store(offset, lerpF32(gs0, gd0, w), kPixelLength + 4); 930 | store(offset, lerpF32(bs0, bd0, w), kPixelLength + 8); 931 | } 932 | } else { 933 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 934 | rd0, rd1, gd0, gd1, bd0, bd1, 935 | pat & 1, (weights & 7)), 936 | kPixelLength); 937 | } 938 | weights >>= 3; 939 | pat >>= 1; 940 | 941 | if (kIsRGBA16F) { 942 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 943 | rd0, rd1, gd0, gd1, bd0, bd1, 944 | pat & 1, (weights & 7)), 945 | kPixelLength * 2); 946 | } else if (kIsRGB32F) { 947 | const w = weight3(weights & 7); 948 | if (pat & 1) { 949 | store(offset, lerpF32(rs1, rd1, w), kPixelLength * 2 + 0); 950 | store(offset, lerpF32(gs1, gd1, w), kPixelLength * 2 + 4); 951 | store(offset, lerpF32(bs1, bd1, w), kPixelLength * 2 + 8); 952 | } else { 953 | store(offset, lerpF32(rs0, rd0, w), kPixelLength * 2 + 0); 954 | store(offset, lerpF32(gs0, gd0, w), kPixelLength * 2 + 4); 955 | store(offset, lerpF32(bs0, bd0, w), kPixelLength * 2 + 8); 956 | } 957 | } else { 958 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 959 | rd0, rd1, gd0, gd1, bd0, bd1, 960 | pat & 1, (weights & 7)), 961 | kPixelLength * 2); 962 | } 963 | weights >>= 3; 964 | pat >>= 1; 965 | 966 | if (kIsRGBA16F) { 967 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 968 | rd0, rd1, gd0, gd1, bd0, bd1, 969 | pat & 1, (weights & 7)), 970 | kPixelLength * 3); 971 | } else if (kIsRGB32F) { 972 | const w = weight3(weights & 7); 973 | if (pat & 1) { 974 | store(offset, lerpF32(rs1, rd1, w), kPixelLength * 3 + 0); 975 | store(offset, lerpF32(gs1, gd1, w), kPixelLength * 3 + 4); 976 | store(offset, lerpF32(bs1, bd1, w), kPixelLength * 3 + 8); 977 | } else { 978 | store(offset, lerpF32(rs0, rd0, w), kPixelLength * 3 + 0); 979 | store(offset, lerpF32(gs0, gd0, w), kPixelLength * 3 + 4); 980 | store(offset, lerpF32(bs0, bd0, w), kPixelLength * 3 + 8); 981 | } 982 | } else { 983 | store(offset, lerp2(rs0, rs1, gs0, gs1, bs0, bs1, 984 | rd0, rd1, gd0, gd1, bd0, bd1, 985 | pat & 1, (weights & 7)), 986 | kPixelLength * 3); 987 | } 988 | weights >>= 3; 989 | pat >>= 1; 990 | 991 | offset += stride; 992 | } 993 | 994 | } 995 | 996 | /** 997 | * Linear interpolation and subsequent final unquantization. 998 | */ 999 | // @ts-ignore 1000 | @inline 1001 | function lerp1( 1002 | rs0: u32, gs0: u32, bs0: u32, 1003 | rd0: u32, gd0: u32, bd0: u32, 1004 | w: u32 1005 | ): T { 1006 | w = weight4(w); 1007 | const r = (rs0 + w * rd0) >> 6; 1008 | const g = (gs0 + w * gd0) >> 6; 1009 | const b = (bs0 + w * bd0) >> 6; 1010 | if (kIsRGBA16F) { 1011 | return unquantizeRGBA16F(r, g, b) as T; 1012 | } 1013 | if (kIsRGB9E5) { 1014 | return unquantizeRGB9E5(r, g, b) as T; 1015 | } 1016 | if (kIsRoundRG11FB10F) { 1017 | return unquantizeRoundRG11FB10F(r, g, b) as T; 1018 | } 1019 | if (kIsTruncRG11FB10F) { 1020 | return unquantizeTruncRG11FB10F(r, g, b) as T; 1021 | } 1022 | if (kIsRoundNoClampRG11FB10F) { 1023 | return unquantizeRoundUnsafeRG11FB10F(r, g, b) as T; 1024 | } 1025 | return unreachable(); 1026 | } 1027 | 1028 | /** 1029 | * Partitioned linear interpolation and subsequent final unquantization. 1030 | */ 1031 | // @ts-ignore 1032 | @inline 1033 | function lerp2( 1034 | rs0: u32, rs1: u32, 1035 | gs0: u32, gs1: u32, 1036 | bs0: u32, bs1: u32, 1037 | rd0: u32, rd1: u32, 1038 | gd0: u32, gd1: u32, 1039 | bd0: u32, bd1: u32, 1040 | p: u32, w: u32 1041 | ): T { 1042 | let r: u32 = 0; 1043 | let g: u32 = 0; 1044 | let b: u32 = 0; 1045 | w = weight3(w); 1046 | if (p) { 1047 | r = (rs1 + w * rd1) >> 6; 1048 | g = (gs1 + w * gd1) >> 6; 1049 | b = (bs1 + w * bd1) >> 6; 1050 | } else { 1051 | r = (rs0 + w * rd0) >> 6; 1052 | g = (gs0 + w * gd0) >> 6; 1053 | b = (bs0 + w * bd0) >> 6; 1054 | } 1055 | if (kIsRGBA16F) { 1056 | return unquantizeRGBA16F(r, g, b) as T; 1057 | } 1058 | if (kIsRGB9E5) { 1059 | return unquantizeRGB9E5(r, g, b) as T; 1060 | } 1061 | if (kIsRoundRG11FB10F) { 1062 | return unquantizeRoundRG11FB10F(r, g, b) as T; 1063 | } 1064 | if (kIsTruncRG11FB10F) { 1065 | return unquantizeTruncRG11FB10F(r, g, b) as T; 1066 | } 1067 | if (kIsRoundNoClampRG11FB10F) { 1068 | return unquantizeRoundUnsafeRG11FB10F(r, g, b) as T; 1069 | } 1070 | return unreachable(); 1071 | } 1072 | 1073 | /** 1074 | * Load interpolation weight for a 4-bit index. 1075 | */ 1076 | // @ts-ignore 1077 | @inline 1078 | function weight4(i: u32): u32 { 1079 | return load(i); 1080 | } 1081 | 1082 | /** 1083 | * Load interpolation weight for a 3-bit index. 1084 | */ 1085 | // @ts-ignore 1086 | @inline 1087 | function weight3(i: u32): u32 { 1088 | return load(i, 16); 1089 | } 1090 | 1091 | /** 1092 | * Load 16-bit pattern for a 5-bit index. 1093 | */ 1094 | // @ts-ignore 1095 | @inline 1096 | function pattern(p: u32): u32 { 1097 | return load(p << 1, 32); 1098 | } 1099 | 1100 | /** 1101 | * Load reversed 6-bit value. 1102 | */ 1103 | // @ts-ignore 1104 | @inline 1105 | function reverse6(n: u32): u32 { 1106 | return load(n, 96); 1107 | } 1108 | 1109 | /** 1110 | * Load unquantized value. 1111 | */ 1112 | // @ts-ignore 1113 | @inline 1114 | function unq(width: i32, value: u32): u32 { 1115 | const base = 160; 1116 | switch (width) { 1117 | case 6: return load(value * 2, base); 1118 | case 7: return load(value * 2, base + 128 * ((1 << 1) - 1)); 1119 | case 8: return load(value * 2, base + 128 * ((1 << 2) - 1)); 1120 | case 9: return load(value * 2, base + 128 * ((1 << 3) - 1)); 1121 | case 10: return load(value * 2, base + 128 * ((1 << 4) - 1)); 1122 | case 11: return load(value * 2, base + 128 * ((1 << 5) - 1)); 1123 | case 12: return load(value * 2, base + 128 * ((1 << 6) - 1)); 1124 | default: return unreachable(); 1125 | } 1126 | } 1127 | 1128 | /** 1129 | * Sign-extend w-bit value. 1130 | */ 1131 | // @ts-ignore 1132 | @inline 1133 | function signExtend(w: u32, value: i32): i32 { 1134 | const s = 32 - w; 1135 | return (value << s) >> s; 1136 | } 1137 | 1138 | /** 1139 | * Get anchor index for a given pattern index. 1140 | */ 1141 | // @ts-ignore 1142 | @inline 1143 | function getAnchor(p: u32): u32 { 1144 | if (p < 16) return 15; 1145 | return (0x22882282F882282F >> ((p & 0xF) << 2)) & 0xF; 1146 | } 1147 | 1148 | /** 1149 | * Scale to 15 bits and pack to 64 bits. 1150 | */ 1151 | // @ts-ignore 1152 | @inline 1153 | function unquantizeRGBA16F(r: u32, g: u32, b: u32): u64 { 1154 | const ru: u64 = (r * 31) >> 6; 1155 | const gu: u64 = (g * 31) >> 6; 1156 | const bu: u64 = (b * 31) >> 6; 1157 | return 0x3C00000000000000 | (bu << 32) | (gu << 16) | ru; 1158 | } 1159 | 1160 | /** 1161 | * Downscale float16 values to 9 bits with a shared 5-bit exponent. 1162 | */ 1163 | // @ts-ignore 1164 | @inline 1165 | function unquantizeRGB9E5(r: u32, g: u32, b: u32): u32 { 1166 | // Regular BC6H_U 16-to-15 unquantization. After it, 1167 | // half-float reinterpretations are guaranteed to be in [0.0, 65504.0] 1168 | // thus implicitly avoiding NaNs and Inf. 1169 | r = (r * 31) >> 6; 1170 | g = (g * 31) >> 6; 1171 | b = (b * 31) >> 6; 1172 | 1173 | // Extract exponents from the higher 5 bits. 1174 | const rExp = r >> 10; 1175 | const gExp = g >> 10; 1176 | const bExp = b >> 10; 1177 | 1178 | // Extract mantissas from the lower 10 bits. 1179 | // As per the float16 spec, add 1024 when the exponent is not zero. 1180 | const rM = (r & 0x3FF) | (rExp ? 0x400 : 0); 1181 | const gM = (g & 0x3FF) | (gExp ? 0x400 : 0); 1182 | const bM = (b & 0x3FF) | (bExp ? 0x400 : 0); 1183 | 1184 | if (rExp | gExp | bExp) { 1185 | // When at least one of RGB exponents is not zero, 1186 | // use the largest one +1 (to even the multiplier) for the packed value. 1187 | const sharedExp = 1 + max(rExp, max(gExp, bExp)); 1188 | 1189 | // Translate the exponent differences into 1190 | // the number of bits to truncate the mantissas by. 1191 | // TODO: Evaluate accuracy and speed with rounding semantics. 1192 | const rShift = 1 + sharedExp - (rExp ? rExp : 1); 1193 | const gShift = 1 + sharedExp - (gExp ? gExp : 1); 1194 | const bShift = 1 + sharedExp - (bExp ? bExp : 1); 1195 | return (sharedExp << 27) | 1196 | (bM >> bShift << 18) | 1197 | (gM >> gShift << 9) | 1198 | (rM >> rShift); 1199 | } else { 1200 | // All three values are float16 denorms. If all mantissas belong 1201 | // to 0..511 range, they could be copied directly with zero exponent. 1202 | // Otherwise, truncate to 9 bits and set the shared exponent to 1. 1203 | const msb = ((rM | gM | bM) >> 9) & 1; 1204 | return (msb << 27) | 1205 | (bM >> msb << 18) | 1206 | (gM >> msb << 9) | 1207 | (rM >> msb); 1208 | } 1209 | } 1210 | 1211 | /** 1212 | * Clamp & scale to 10-11 bits with rounding and pack to 32 bits. 1213 | */ 1214 | // @ts-ignore 1215 | @inline 1216 | function unquantizeRoundRG11FB10F(r: u32, g: u32, b: u32): u32 { 1217 | // Clamp inputs to avoid 10- or 11-bit infinity values 1218 | r = min(r, 65519); 1219 | g = min(g, 65519); 1220 | b = min(b, 65502); 1221 | 1222 | // Rescale floating-point representations afterwards 1223 | r = (r * 0x001F + 0x000200) >> 10; 1224 | g = (g * 0x003E + 0x000400) & 0x003FF800; 1225 | b = (b * 0xF800 + 0x200000) & 0xFFC00000; 1226 | return b | g | r; 1227 | } 1228 | 1229 | /** 1230 | * Scale to 10-11 bits with truncation and pack to 32 bits. 1231 | */ 1232 | // @ts-ignore 1233 | @inline 1234 | function unquantizeTruncRG11FB10F(r: u32, g: u32, b: u32): u32 { 1235 | // Copy exponents and trunc mantissas 1236 | r = (r * 0x001F) >> 10; 1237 | g = (g * 0x003E) & 0x003FF800; 1238 | b = (b * 0xF800) & 0xFFC00000; 1239 | return b | g | r; 1240 | } 1241 | 1242 | /** 1243 | * Scale to 10-11 bits with rounding and pack to 32 bits. 1244 | * Values greater than finite maximums for 10- and 11-bit 1245 | * floats will be set to Infinity. 1246 | */ 1247 | // @ts-ignore 1248 | @inline 1249 | function unquantizeRoundUnsafeRG11FB10F(r: u32, g: u32, b: u32): u32 { 1250 | r = (r * 0x001F + 0x000200) >> 10; 1251 | g = (g * 0x003E + 0x000400) & 0x003FF800; 1252 | b = (b * 0xF800 + 0x200000) & 0xFFC00000; 1253 | return b | g | r; 1254 | } 1255 | 1256 | /** 1257 | * Apply BC6H_U interpolation, final unquantization, 1258 | * and convert the result to a single-precision float. 1259 | */ 1260 | // @ts-ignore 1261 | @inline 1262 | function lerpF32(cs0: u32, cd0: u32, w: u32): u32 { 1263 | const c = (((cs0 + w * cd0) >> 6) * 31) >> 6; 1264 | 1265 | if (c == 0) return 0; 1266 | 1267 | // Normalized 1268 | if (c > 1023) return (c << 13) + 0x38000000; 1269 | 1270 | // Half-float denorms 1271 | const clzC = clz(c); 1272 | return ((c << (clzC - 8)) ^ 0x800000) + 0x43000000 - (clzC << 23); 1273 | } 1274 | -------------------------------------------------------------------------------- /assembly/generator.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Khronos Group Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | const kUserDataOffset = 65536; 6 | 7 | /** 8 | * Generate single-mode BC6H data 9 | * @param mode - Compressed BC6H Mode Index. Input [0..13] range is mapped to [0, 1, 2, 6, 10, 14, 18, 22, 26, 30, 3, 7, 11, 15, 19, 23, 27, 31] actual BC6H modes. 10 | * @param nBlocks - The total number of BC6H blocks to generate. 11 | * @returns Actual BC6H mode index or -1 on failure. 12 | */ 13 | export function generate(mode: i32, nBlocks: i32): i32 { 14 | if (mode > 17 || mode < 0 || nBlocks < 0) return -1; 15 | 16 | const totalBytes = nBlocks * 16; 17 | if ((memory.size() - 1) * 65536 < totalBytes) return -1; 18 | 19 | const actualMode = getActualMode(mode); 20 | for (let seed = 0; seed < nBlocks; seed++) { 21 | writeBlock(actualMode, seed); 22 | } 23 | return actualMode; 24 | } 25 | 26 | /** 27 | * Generate multi-mode BC6H data 28 | * @param nBlocks - The total number of BC6H blocks. 29 | * @returns Zero on success or -1 on failure. 30 | */ 31 | export function generateAll(nBlocks: i32): i32 { 32 | if (nBlocks < 0) return -1; 33 | 34 | const totalBytes = nBlocks * 16; 35 | if ((memory.size() - 1) * 65536 < totalBytes) return -1; 36 | 37 | for (let seed = 0; seed < nBlocks; seed++) { 38 | // Restrict reserved modes 39 | const actualMode = getActualMode((seed * 3 + seed / 14 + 1) % 14); 40 | writeBlock(actualMode, seed); 41 | } 42 | return 0; 43 | } 44 | 45 | /** 46 | * Generate multi-mode BC6H data containing only single-subset blocks. 47 | * @param nBlocks - The total number of BC6H blocks. 48 | * @returns Zero on success or -1 on failure. 49 | */ 50 | export function generateAllSingleSubset(nBlocks: u32): i32 { 51 | const totalBytes = nBlocks * 16; 52 | if ((memory.size() - 1) * 65536 < totalBytes) return -1; 53 | 54 | for (let seed: u64 = 0; seed < nBlocks; seed++) { 55 | const actualMode = getActualMode(10 + ((seed * 3 + seed / 4 + 1) % 4)); 56 | writeBlock(actualMode, seed); 57 | } 58 | return 0; 59 | } 60 | 61 | /** 62 | * Generate multi-mode BC6H data containing only dual-subset blocks. 63 | * @param nBlocks - The total number of BC6H blocks. 64 | * @returns Zero on success or -1 on failure. 65 | */ 66 | export function generateAllDualSubset(nBlocks: u32): i32 { 67 | const totalBytes = nBlocks * 16; 68 | if ((memory.size() - 1) * 65536 < totalBytes) return -1; 69 | 70 | for (let seed: u64 = 0; seed < nBlocks; seed++) { 71 | const actualMode = getActualMode((seed * 3 + seed / 10 + 1) % 10); 72 | writeBlock(actualMode, seed); 73 | } 74 | return 0; 75 | } 76 | 77 | function writeBlock(mode: i32, seed: u64): void { 78 | let r0: u64 = mode; 79 | r0 |= crc64(0, seed) << ((mode < 2) ? 2 : 5); 80 | 81 | let r1 = crc64(r0, seed); 82 | if ((mode & 3) != 3) { 83 | const pattern = (seed & 0x1F) << 13; 84 | r1 = (r1 & 0xFFFFFFFFFFFC1FFF) | pattern; 85 | } 86 | 87 | const offset = kUserDataOffset + seed * 16; 88 | store(offset, r0, 0); 89 | store(offset, r1, 8); 90 | } 91 | 92 | function getActualMode(mode: i32): i32 { 93 | switch (mode) { 94 | case 0: return 0; 95 | case 1: return 1; 96 | case 2: return 2; 97 | case 3: return 6; 98 | case 4: return 10; 99 | case 5: return 14; 100 | case 6: return 18; 101 | case 7: return 22; 102 | case 8: return 26; 103 | case 9: return 30; 104 | case 10: return 3; 105 | case 11: return 7; 106 | case 12: return 11; 107 | case 13: return 15; 108 | case 14: return 19; 109 | case 15: return 23; 110 | case 16: return 27; 111 | case 17: return 31; 112 | default: return unreachable(); 113 | } 114 | } 115 | 116 | const crcOffset = memory.data([ 117 | 0x0000000000000000, 118 | 0x7AD870C830358979, 119 | 0xF5B0E190606B12F2, 120 | 0x8F689158505E9B8B, 121 | 0xC038E5739841B68F, 122 | 0xBAE095BBA8743FF6, 123 | 0x358804E3F82AA47D, 124 | 0x4F50742BC81F2D04, 125 | 0xAB28ECB46814FE75, 126 | 0xD1F09C7C5821770C, 127 | 0x5E980D24087FEC87, 128 | 0x24407DEC384A65FE, 129 | 0x6B1009C7F05548FA, 130 | 0x11C8790FC060C183, 131 | 0x9EA0E857903E5A08, 132 | 0xE478989FA00BD371, 133 | 0x7D08FF3B88BE6F81, 134 | 0x07D08FF3B88BE6F8, 135 | 0x88B81EABE8D57D73, 136 | 0xF2606E63D8E0F40A, 137 | 0xBD301A4810FFD90E, 138 | 0xC7E86A8020CA5077, 139 | 0x4880FBD87094CBFC, 140 | 0x32588B1040A14285, 141 | 0xD620138FE0AA91F4, 142 | 0xACF86347D09F188D, 143 | 0x2390F21F80C18306, 144 | 0x594882D7B0F40A7F, 145 | 0x1618F6FC78EB277B, 146 | 0x6CC0863448DEAE02, 147 | 0xE3A8176C18803589, 148 | 0x997067A428B5BCF0, 149 | 0xFA11FE77117CDF02, 150 | 0x80C98EBF2149567B, 151 | 0x0FA11FE77117CDF0, 152 | 0x75796F2F41224489, 153 | 0x3A291B04893D698D, 154 | 0x40F16BCCB908E0F4, 155 | 0xCF99FA94E9567B7F, 156 | 0xB5418A5CD963F206, 157 | 0x513912C379682177, 158 | 0x2BE1620B495DA80E, 159 | 0xA489F35319033385, 160 | 0xDE51839B2936BAFC, 161 | 0x9101F7B0E12997F8, 162 | 0xEBD98778D11C1E81, 163 | 0x64B116208142850A, 164 | 0x1E6966E8B1770C73, 165 | 0x8719014C99C2B083, 166 | 0xFDC17184A9F739FA, 167 | 0x72A9E0DCF9A9A271, 168 | 0x08719014C99C2B08, 169 | 0x4721E43F0183060C, 170 | 0x3DF994F731B68F75, 171 | 0xB29105AF61E814FE, 172 | 0xC849756751DD9D87, 173 | 0x2C31EDF8F1D64EF6, 174 | 0x56E99D30C1E3C78F, 175 | 0xD9810C6891BD5C04, 176 | 0xA3597CA0A188D57D, 177 | 0xEC09088B6997F879, 178 | 0x96D1784359A27100, 179 | 0x19B9E91B09FCEA8B, 180 | 0x636199D339C963F2, 181 | 0xDF7ADABD7A6E2D6F, 182 | 0xA5A2AA754A5BA416, 183 | 0x2ACA3B2D1A053F9D, 184 | 0x50124BE52A30B6E4, 185 | 0x1F423FCEE22F9BE0, 186 | 0x659A4F06D21A1299, 187 | 0xEAF2DE5E82448912, 188 | 0x902AAE96B271006B, 189 | 0x74523609127AD31A, 190 | 0x0E8A46C1224F5A63, 191 | 0x81E2D7997211C1E8, 192 | 0xFB3AA75142244891, 193 | 0xB46AD37A8A3B6595, 194 | 0xCEB2A3B2BA0EECEC, 195 | 0x41DA32EAEA507767, 196 | 0x3B024222DA65FE1E, 197 | 0xA2722586F2D042EE, 198 | 0xD8AA554EC2E5CB97, 199 | 0x57C2C41692BB501C, 200 | 0x2D1AB4DEA28ED965, 201 | 0x624AC0F56A91F461, 202 | 0x1892B03D5AA47D18, 203 | 0x97FA21650AFAE693, 204 | 0xED2251AD3ACF6FEA, 205 | 0x095AC9329AC4BC9B, 206 | 0x7382B9FAAAF135E2, 207 | 0xFCEA28A2FAAFAE69, 208 | 0x8632586ACA9A2710, 209 | 0xC9622C4102850A14, 210 | 0xB3BA5C8932B0836D, 211 | 0x3CD2CDD162EE18E6, 212 | 0x460ABD1952DB919F, 213 | 0x256B24CA6B12F26D, 214 | 0x5FB354025B277B14, 215 | 0xD0DBC55A0B79E09F, 216 | 0xAA03B5923B4C69E6, 217 | 0xE553C1B9F35344E2, 218 | 0x9F8BB171C366CD9B, 219 | 0x10E3202993385610, 220 | 0x6A3B50E1A30DDF69, 221 | 0x8E43C87E03060C18, 222 | 0xF49BB8B633338561, 223 | 0x7BF329EE636D1EEA, 224 | 0x012B592653589793, 225 | 0x4E7B2D0D9B47BA97, 226 | 0x34A35DC5AB7233EE, 227 | 0xBBCBCC9DFB2CA865, 228 | 0xC113BC55CB19211C, 229 | 0x5863DBF1E3AC9DEC, 230 | 0x22BBAB39D3991495, 231 | 0xADD33A6183C78F1E, 232 | 0xD70B4AA9B3F20667, 233 | 0x985B3E827BED2B63, 234 | 0xE2834E4A4BD8A21A, 235 | 0x6DEBDF121B863991, 236 | 0x1733AFDA2BB3B0E8, 237 | 0xF34B37458BB86399, 238 | 0x8993478DBB8DEAE0, 239 | 0x06FBD6D5EBD3716B, 240 | 0x7C23A61DDBE6F812, 241 | 0x3373D23613F9D516, 242 | 0x49ABA2FE23CC5C6F, 243 | 0xC6C333A67392C7E4, 244 | 0xBC1B436E43A74E9D, 245 | 0x95AC9329AC4BC9B5, 246 | 0xEF74E3E19C7E40CC, 247 | 0x601C72B9CC20DB47, 248 | 0x1AC40271FC15523E, 249 | 0x5594765A340A7F3A, 250 | 0x2F4C0692043FF643, 251 | 0xA02497CA54616DC8, 252 | 0xDAFCE7026454E4B1, 253 | 0x3E847F9DC45F37C0, 254 | 0x445C0F55F46ABEB9, 255 | 0xCB349E0DA4342532, 256 | 0xB1ECEEC59401AC4B, 257 | 0xFEBC9AEE5C1E814F, 258 | 0x8464EA266C2B0836, 259 | 0x0B0C7B7E3C7593BD, 260 | 0x71D40BB60C401AC4, 261 | 0xE8A46C1224F5A634, 262 | 0x927C1CDA14C02F4D, 263 | 0x1D148D82449EB4C6, 264 | 0x67CCFD4A74AB3DBF, 265 | 0x289C8961BCB410BB, 266 | 0x5244F9A98C8199C2, 267 | 0xDD2C68F1DCDF0249, 268 | 0xA7F41839ECEA8B30, 269 | 0x438C80A64CE15841, 270 | 0x3954F06E7CD4D138, 271 | 0xB63C61362C8A4AB3, 272 | 0xCCE411FE1CBFC3CA, 273 | 0x83B465D5D4A0EECE, 274 | 0xF96C151DE49567B7, 275 | 0x76048445B4CBFC3C, 276 | 0x0CDCF48D84FE7545, 277 | 0x6FBD6D5EBD3716B7, 278 | 0x15651D968D029FCE, 279 | 0x9A0D8CCEDD5C0445, 280 | 0xE0D5FC06ED698D3C, 281 | 0xAF85882D2576A038, 282 | 0xD55DF8E515432941, 283 | 0x5A3569BD451DB2CA, 284 | 0x20ED197575283BB3, 285 | 0xC49581EAD523E8C2, 286 | 0xBE4DF122E51661BB, 287 | 0x3125607AB548FA30, 288 | 0x4BFD10B2857D7349, 289 | 0x04AD64994D625E4D, 290 | 0x7E7514517D57D734, 291 | 0xF11D85092D094CBF, 292 | 0x8BC5F5C11D3CC5C6, 293 | 0x12B5926535897936, 294 | 0x686DE2AD05BCF04F, 295 | 0xE70573F555E26BC4, 296 | 0x9DDD033D65D7E2BD, 297 | 0xD28D7716ADC8CFB9, 298 | 0xA85507DE9DFD46C0, 299 | 0x273D9686CDA3DD4B, 300 | 0x5DE5E64EFD965432, 301 | 0xB99D7ED15D9D8743, 302 | 0xC3450E196DA80E3A, 303 | 0x4C2D9F413DF695B1, 304 | 0x36F5EF890DC31CC8, 305 | 0x79A59BA2C5DC31CC, 306 | 0x037DEB6AF5E9B8B5, 307 | 0x8C157A32A5B7233E, 308 | 0xF6CD0AFA9582AA47, 309 | 0x4AD64994D625E4DA, 310 | 0x300E395CE6106DA3, 311 | 0xBF66A804B64EF628, 312 | 0xC5BED8CC867B7F51, 313 | 0x8AEEACE74E645255, 314 | 0xF036DC2F7E51DB2C, 315 | 0x7F5E4D772E0F40A7, 316 | 0x05863DBF1E3AC9DE, 317 | 0xE1FEA520BE311AAF, 318 | 0x9B26D5E88E0493D6, 319 | 0x144E44B0DE5A085D, 320 | 0x6E963478EE6F8124, 321 | 0x21C640532670AC20, 322 | 0x5B1E309B16452559, 323 | 0xD476A1C3461BBED2, 324 | 0xAEAED10B762E37AB, 325 | 0x37DEB6AF5E9B8B5B, 326 | 0x4D06C6676EAE0222, 327 | 0xC26E573F3EF099A9, 328 | 0xB8B627F70EC510D0, 329 | 0xF7E653DCC6DA3DD4, 330 | 0x8D3E2314F6EFB4AD, 331 | 0x0256B24CA6B12F26, 332 | 0x788EC2849684A65F, 333 | 0x9CF65A1B368F752E, 334 | 0xE62E2AD306BAFC57, 335 | 0x6946BB8B56E467DC, 336 | 0x139ECB4366D1EEA5, 337 | 0x5CCEBF68AECEC3A1, 338 | 0x2616CFA09EFB4AD8, 339 | 0xA97E5EF8CEA5D153, 340 | 0xD3A62E30FE90582A, 341 | 0xB0C7B7E3C7593BD8, 342 | 0xCA1FC72BF76CB2A1, 343 | 0x45775673A732292A, 344 | 0x3FAF26BB9707A053, 345 | 0x70FF52905F188D57, 346 | 0x0A2722586F2D042E, 347 | 0x854FB3003F739FA5, 348 | 0xFF97C3C80F4616DC, 349 | 0x1BEF5B57AF4DC5AD, 350 | 0x61372B9F9F784CD4, 351 | 0xEE5FBAC7CF26D75F, 352 | 0x9487CA0FFF135E26, 353 | 0xDBD7BE24370C7322, 354 | 0xA10FCEEC0739FA5B, 355 | 0x2E675FB4576761D0, 356 | 0x54BF2F7C6752E8A9, 357 | 0xCDCF48D84FE75459, 358 | 0xB71738107FD2DD20, 359 | 0x387FA9482F8C46AB, 360 | 0x42A7D9801FB9CFD2, 361 | 0x0DF7ADABD7A6E2D6, 362 | 0x772FDD63E7936BAF, 363 | 0xF8474C3BB7CDF024, 364 | 0x829F3CF387F8795D, 365 | 0x66E7A46C27F3AA2C, 366 | 0x1C3FD4A417C62355, 367 | 0x935745FC4798B8DE, 368 | 0xE98F353477AD31A7, 369 | 0xA6DF411FBFB21CA3, 370 | 0xDC0731D78F8795DA, 371 | 0x536FA08FDFD90E51, 372 | 0x29B7D047EFEC8728, 373 | ]); 374 | 375 | function crc64(crc: u64, seed: u64): u64 { 376 | let byte: usize; 377 | 378 | byte = usize((crc ^ (seed & 0xFF)) & 0xFF); 379 | crc = load(byte, crcOffset) ^ (crc >> 8); 380 | 381 | byte = usize((crc ^ (seed >> 8 & 0xFF)) & 0xFF); 382 | crc = load(byte, crcOffset) ^ (crc >> 8); 383 | 384 | byte = usize((crc ^ (seed >> 16 & 0xFF)) & 0xFF); 385 | crc = load(byte, crcOffset) ^ (crc >> 8); 386 | 387 | byte = usize((crc ^ (seed >> 24 & 0xFF)) & 0xFF); 388 | crc = load(byte, crcOffset) ^ (crc >> 8); 389 | 390 | byte = usize((crc ^ (seed >> 32 & 0xFF)) & 0xFF); 391 | crc = load(byte, crcOffset) ^ (crc >> 8); 392 | 393 | byte = usize((crc ^ (seed >> 40 & 0xFF)) & 0xFF); 394 | crc = load(byte, crcOffset) ^ (crc >> 8); 395 | 396 | byte = usize((crc ^ (seed >> 48 & 0xFF)) & 0xFF); 397 | crc = load(byte, crcOffset) ^ (crc >> 8); 398 | 399 | byte = usize((crc ^ (seed >> 58)) & 0xFF); 400 | crc = load(byte, crcOffset) ^ (crc >> 8); 401 | 402 | return crc; 403 | } 404 | -------------------------------------------------------------------------------- /assembly/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "assemblyscript/std/assembly.json", 3 | "include": [ 4 | "./**/*.ts" 5 | ] 6 | } -------------------------------------------------------------------------------- /build/bc6hu-r11fg11fb10f_round.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/bc6hu-r11fg11fb10f_round.wasm -------------------------------------------------------------------------------- /build/bc6hu-r11fg11fb10f_round_noclamp.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/bc6hu-r11fg11fb10f_round_noclamp.wasm -------------------------------------------------------------------------------- /build/bc6hu-r11fg11fb10f_trunc.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/bc6hu-r11fg11fb10f_trunc.wasm -------------------------------------------------------------------------------- /build/bc6hu-r11fg11fb10f_trunc.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) 3 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 4 | (import "env" "memory" (memory $0 0)) 5 | (global $assembly/decoder/firstRun (mut i32) (i32.const 1)) 6 | (export "memory" (memory $0)) 7 | (export "decode" (func $assembly/decoder/decode)) 8 | (func $assembly/decoder/decodeBlock (param $0 i32) (param $1 i32) (param $2 i32) 9 | (local $3 i32) 10 | (local $4 i32) 11 | (local $5 i32) 12 | (local $6 i64) 13 | (local $7 i32) 14 | (local $8 i32) 15 | (local $9 i32) 16 | (local $10 i32) 17 | (local $11 i32) 18 | (local $12 i32) 19 | (local $13 i32) 20 | (local $14 i32) 21 | (local $15 i32) 22 | (local $16 i32) 23 | (local $17 i32) 24 | (local $18 i64) 25 | (local $19 i32) 26 | (local $20 i32) 27 | (local $21 i32) 28 | (local $22 i32) 29 | (local $23 i32) 30 | (local $24 i32) 31 | (local $25 i32) 32 | local.get $0 33 | i64.load offset=8 34 | local.set $18 35 | local.get $0 36 | i64.load 37 | local.tee $6 38 | i64.const 3 39 | i64.and 40 | i64.const 3 41 | i64.eq 42 | if 43 | local.get $6 44 | i32.wrap_i64 45 | local.set $4 46 | local.get $6 47 | i64.const 32 48 | i64.shr_u 49 | i32.wrap_i64 50 | local.set $0 51 | local.get $18 52 | i32.wrap_i64 53 | local.set $12 54 | block $break|0 55 | block $case3|0 56 | block $case2|0 57 | block $case1|0 58 | block $case0|0 59 | local.get $6 60 | i32.wrap_i64 61 | i32.const 31 62 | i32.and 63 | i32.const 3 64 | i32.sub 65 | br_table $case0|0 $break|0 $break|0 $break|0 $case1|0 $break|0 $break|0 $break|0 $case2|0 $break|0 $break|0 $break|0 $case3|0 $break|0 66 | end 67 | local.get $4 68 | i32.const 5 69 | i32.shr_u 70 | i32.const 1023 71 | i32.and 72 | i32.const 1 73 | i32.shl 74 | i32.load16_u offset=2080 75 | local.set $9 76 | local.get $4 77 | i32.const 15 78 | i32.shr_u 79 | i32.const 1023 80 | i32.and 81 | i32.const 1 82 | i32.shl 83 | i32.load16_u offset=2080 84 | local.set $13 85 | local.get $6 86 | i64.const 25 87 | i64.shr_u 88 | i64.const 1023 89 | i64.and 90 | i32.wrap_i64 91 | i32.const 1 92 | i32.shl 93 | i32.load16_u offset=2080 94 | local.set $10 95 | local.get $0 96 | i32.const 3 97 | i32.shr_u 98 | i32.const 1023 99 | i32.and 100 | i32.const 1 101 | i32.shl 102 | i32.load16_u offset=2080 103 | local.set $14 104 | local.get $0 105 | i32.const 13 106 | i32.shr_u 107 | i32.const 1023 108 | i32.and 109 | i32.const 1 110 | i32.shl 111 | i32.load16_u offset=2080 112 | local.set $15 113 | local.get $12 114 | i32.const 9 115 | i32.shl 116 | i32.const 512 117 | i32.and 118 | local.get $0 119 | i32.const 23 120 | i32.shr_u 121 | i32.or 122 | i32.const 1 123 | i32.shl 124 | i32.load16_u offset=2080 125 | local.set $11 126 | br $break|0 127 | end 128 | local.get $0 129 | i32.const 2 130 | i32.shr_u 131 | i32.const 1024 132 | i32.and 133 | local.get $4 134 | i32.const 5 135 | i32.shr_u 136 | i32.const 1023 137 | i32.and 138 | i32.or 139 | local.tee $11 140 | i32.const 1 141 | i32.shl 142 | i32.load16_u offset=4128 143 | local.set $9 144 | local.get $0 145 | i32.const 12 146 | i32.shr_u 147 | i32.const 1024 148 | i32.and 149 | local.get $4 150 | i32.const 15 151 | i32.shr_u 152 | i32.const 1023 153 | i32.and 154 | i32.or 155 | local.tee $4 156 | i32.const 1 157 | i32.shl 158 | i32.load16_u offset=4128 159 | local.set $13 160 | local.get $6 161 | i64.const 25 162 | i64.shr_u 163 | i64.const 1023 164 | i64.and 165 | i32.wrap_i64 166 | local.get $12 167 | i32.const 10 168 | i32.shl 169 | i32.const 1024 170 | i32.and 171 | i32.or 172 | local.tee $12 173 | i32.const 1 174 | i32.shl 175 | i32.load16_u offset=4128 176 | local.set $10 177 | local.get $11 178 | local.get $0 179 | i32.const 3 180 | i32.shr_u 181 | i32.const 23 182 | i32.shl 183 | i32.const 23 184 | i32.shr_s 185 | i32.add 186 | i32.const 2047 187 | i32.and 188 | i32.const 1 189 | i32.shl 190 | i32.load16_u offset=4128 191 | local.set $14 192 | local.get $4 193 | local.get $0 194 | i32.const 13 195 | i32.shr_u 196 | i32.const 23 197 | i32.shl 198 | i32.const 23 199 | i32.shr_s 200 | i32.add 201 | i32.const 2047 202 | i32.and 203 | i32.const 1 204 | i32.shl 205 | i32.load16_u offset=4128 206 | local.set $15 207 | local.get $12 208 | local.get $0 209 | i32.const 23 210 | i32.shr_u 211 | i32.const 23 212 | i32.shl 213 | i32.const 23 214 | i32.shr_s 215 | i32.add 216 | i32.const 2047 217 | i32.and 218 | i32.const 1 219 | i32.shl 220 | i32.load16_u offset=4128 221 | local.set $11 222 | br $break|0 223 | end 224 | local.get $4 225 | i32.const 5 226 | i32.shr_u 227 | i32.const 1023 228 | i32.and 229 | local.get $0 230 | i32.const 2048 231 | i32.and 232 | local.get $0 233 | i32.const 2 234 | i32.shr_u 235 | i32.const 1024 236 | i32.and 237 | i32.or 238 | i32.or 239 | local.tee $11 240 | i32.const 1 241 | i32.shl 242 | i32.load16_u offset=8224 243 | local.set $9 244 | local.get $4 245 | i32.const 15 246 | i32.shr_u 247 | i32.const 1023 248 | i32.and 249 | local.get $0 250 | i32.const 10 251 | i32.shr_u 252 | i32.const 2048 253 | i32.and 254 | local.get $0 255 | i32.const 12 256 | i32.shr_u 257 | i32.const 1024 258 | i32.and 259 | i32.or 260 | i32.or 261 | local.tee $4 262 | i32.const 1 263 | i32.shl 264 | i32.load16_u offset=8224 265 | local.set $13 266 | local.get $6 267 | i64.const 25 268 | i64.shr_u 269 | i64.const 1023 270 | i64.and 271 | i32.wrap_i64 272 | local.get $0 273 | i32.const 20 274 | i32.shr_u 275 | i32.const 2048 276 | i32.and 277 | local.get $12 278 | i32.const 10 279 | i32.shl 280 | i32.const 1024 281 | i32.and 282 | i32.or 283 | i32.or 284 | local.tee $12 285 | i32.const 1 286 | i32.shl 287 | i32.load16_u offset=8224 288 | local.set $10 289 | local.get $11 290 | local.get $0 291 | i32.const 3 292 | i32.shr_u 293 | i32.const 24 294 | i32.shl 295 | i32.const 24 296 | i32.shr_s 297 | i32.add 298 | i32.const 4095 299 | i32.and 300 | i32.const 1 301 | i32.shl 302 | i32.load16_u offset=8224 303 | local.set $14 304 | local.get $4 305 | local.get $0 306 | i32.const 13 307 | i32.shr_u 308 | i32.const 24 309 | i32.shl 310 | i32.const 24 311 | i32.shr_s 312 | i32.add 313 | i32.const 4095 314 | i32.and 315 | i32.const 1 316 | i32.shl 317 | i32.load16_u offset=8224 318 | local.set $15 319 | local.get $12 320 | local.get $0 321 | i32.const 23 322 | i32.shr_u 323 | i32.const 24 324 | i32.shl 325 | i32.const 24 326 | i32.shr_s 327 | i32.add 328 | i32.const 4095 329 | i32.and 330 | i32.const 1 331 | i32.shl 332 | i32.load16_u offset=8224 333 | local.set $11 334 | br $break|0 335 | end 336 | local.get $4 337 | i32.const 5 338 | i32.shr_u 339 | i32.const 1023 340 | i32.and 341 | local.get $0 342 | i32.const 7 343 | i32.shr_u 344 | i32.const 63 345 | i32.and 346 | i32.load8_u offset=96 347 | i32.const 10 348 | i32.shl 349 | i32.or 350 | local.tee $9 351 | local.get $0 352 | i32.const 3 353 | i32.shr_u 354 | i32.const 28 355 | i32.shl 356 | i32.const 28 357 | i32.shr_s 358 | i32.add 359 | i32.const 65535 360 | i32.and 361 | local.set $14 362 | local.get $4 363 | i32.const 15 364 | i32.shr_u 365 | i32.const 1023 366 | i32.and 367 | local.get $0 368 | i32.const 17 369 | i32.shr_u 370 | i32.const 63 371 | i32.and 372 | i32.load8_u offset=96 373 | i32.const 10 374 | i32.shl 375 | i32.or 376 | local.tee $13 377 | local.get $0 378 | i32.const 13 379 | i32.shr_u 380 | i32.const 28 381 | i32.shl 382 | i32.const 28 383 | i32.shr_s 384 | i32.add 385 | i32.const 65535 386 | i32.and 387 | local.set $15 388 | local.get $6 389 | i64.const 25 390 | i64.shr_u 391 | i64.const 1023 392 | i64.and 393 | i32.wrap_i64 394 | local.get $0 395 | i32.const 27 396 | i32.shr_u 397 | i32.load8_u offset=96 398 | local.get $12 399 | i32.const 1 400 | i32.and 401 | i32.or 402 | i32.const 10 403 | i32.shl 404 | i32.or 405 | local.tee $10 406 | local.get $0 407 | i32.const 23 408 | i32.shr_u 409 | i32.const 28 410 | i32.shl 411 | i32.const 28 412 | i32.shr_s 413 | i32.add 414 | i32.const 65535 415 | i32.and 416 | local.set $11 417 | end 418 | local.get $18 419 | i64.const -16 420 | i64.and 421 | local.get $18 422 | i64.const 1 423 | i64.shr_u 424 | i64.const 7 425 | i64.and 426 | i64.or 427 | local.set $6 428 | local.get $9 429 | i32.const 6 430 | i32.shl 431 | i32.const 32 432 | i32.add 433 | local.set $0 434 | local.get $13 435 | i32.const 6 436 | i32.shl 437 | i32.const 32 438 | i32.add 439 | local.set $4 440 | local.get $10 441 | i32.const 6 442 | i32.shl 443 | i32.const 32 444 | i32.add 445 | local.set $12 446 | local.get $14 447 | local.get $9 448 | i32.sub 449 | local.set $9 450 | local.get $15 451 | local.get $13 452 | i32.sub 453 | local.set $13 454 | local.get $11 455 | local.get $10 456 | i32.sub 457 | local.set $11 458 | loop $for-loop|19 459 | local.get $3 460 | i32.const 4 461 | i32.lt_s 462 | if 463 | local.get $1 464 | local.get $12 465 | local.get $11 466 | local.get $6 467 | i32.wrap_i64 468 | i32.const 15 469 | i32.and 470 | i32.load8_u 471 | local.tee $10 472 | i32.mul 473 | i32.add 474 | i32.const 6 475 | i32.shr_u 476 | i32.const 63488 477 | i32.mul 478 | i32.const -4194304 479 | i32.and 480 | local.get $4 481 | local.get $10 482 | local.get $13 483 | i32.mul 484 | i32.add 485 | i32.const 6 486 | i32.shr_u 487 | i32.const 62 488 | i32.mul 489 | i32.const 4192256 490 | i32.and 491 | i32.or 492 | local.get $0 493 | local.get $9 494 | local.get $10 495 | i32.mul 496 | i32.add 497 | i32.const 6 498 | i32.shr_u 499 | i32.const 31 500 | i32.mul 501 | i32.const 10 502 | i32.shr_u 503 | i32.or 504 | i32.store 505 | local.get $1 506 | local.get $12 507 | local.get $11 508 | local.get $6 509 | i64.const 4 510 | i64.shr_u 511 | local.tee $6 512 | i32.wrap_i64 513 | i32.const 15 514 | i32.and 515 | i32.load8_u 516 | local.tee $10 517 | i32.mul 518 | i32.add 519 | i32.const 6 520 | i32.shr_u 521 | i32.const 63488 522 | i32.mul 523 | i32.const -4194304 524 | i32.and 525 | local.get $4 526 | local.get $10 527 | local.get $13 528 | i32.mul 529 | i32.add 530 | i32.const 6 531 | i32.shr_u 532 | i32.const 62 533 | i32.mul 534 | i32.const 4192256 535 | i32.and 536 | i32.or 537 | local.get $0 538 | local.get $9 539 | local.get $10 540 | i32.mul 541 | i32.add 542 | i32.const 6 543 | i32.shr_u 544 | i32.const 31 545 | i32.mul 546 | i32.const 10 547 | i32.shr_u 548 | i32.or 549 | i32.store offset=4 550 | local.get $1 551 | local.get $12 552 | local.get $11 553 | local.get $6 554 | i64.const 4 555 | i64.shr_u 556 | local.tee $6 557 | i32.wrap_i64 558 | i32.const 15 559 | i32.and 560 | i32.load8_u 561 | local.tee $10 562 | i32.mul 563 | i32.add 564 | i32.const 6 565 | i32.shr_u 566 | i32.const 63488 567 | i32.mul 568 | i32.const -4194304 569 | i32.and 570 | local.get $4 571 | local.get $10 572 | local.get $13 573 | i32.mul 574 | i32.add 575 | i32.const 6 576 | i32.shr_u 577 | i32.const 62 578 | i32.mul 579 | i32.const 4192256 580 | i32.and 581 | i32.or 582 | local.get $0 583 | local.get $9 584 | local.get $10 585 | i32.mul 586 | i32.add 587 | i32.const 6 588 | i32.shr_u 589 | i32.const 31 590 | i32.mul 591 | i32.const 10 592 | i32.shr_u 593 | i32.or 594 | i32.store offset=8 595 | local.get $1 596 | local.get $12 597 | local.get $11 598 | local.get $6 599 | i64.const 4 600 | i64.shr_u 601 | local.tee $6 602 | i32.wrap_i64 603 | i32.const 15 604 | i32.and 605 | i32.load8_u 606 | local.tee $10 607 | i32.mul 608 | i32.add 609 | i32.const 6 610 | i32.shr_u 611 | i32.const 63488 612 | i32.mul 613 | i32.const -4194304 614 | i32.and 615 | local.get $4 616 | local.get $10 617 | local.get $13 618 | i32.mul 619 | i32.add 620 | i32.const 6 621 | i32.shr_u 622 | i32.const 62 623 | i32.mul 624 | i32.const 4192256 625 | i32.and 626 | i32.or 627 | local.get $0 628 | local.get $9 629 | local.get $10 630 | i32.mul 631 | i32.add 632 | i32.const 6 633 | i32.shr_u 634 | i32.const 31 635 | i32.mul 636 | i32.const 10 637 | i32.shr_u 638 | i32.or 639 | i32.store offset=12 640 | local.get $6 641 | i64.const 4 642 | i64.shr_u 643 | local.set $6 644 | local.get $1 645 | local.get $2 646 | i32.add 647 | local.set $1 648 | local.get $3 649 | i32.const 1 650 | i32.add 651 | local.set $3 652 | br $for-loop|19 653 | end 654 | end 655 | else 656 | local.get $1 657 | local.set $3 658 | local.get $6 659 | i32.wrap_i64 660 | local.set $1 661 | local.get $6 662 | i64.const 32 663 | i64.shr_u 664 | i32.wrap_i64 665 | local.set $0 666 | local.get $18 667 | i32.wrap_i64 668 | local.set $4 669 | block $break|20 670 | block $case9|20 671 | block $case8|20 672 | block $case7|20 673 | block $case6|20 674 | block $case5|20 675 | block $case4|20 676 | block $case3|20 677 | block $case2|20 678 | block $case1|20 679 | block $case0|20 680 | local.get $6 681 | i32.wrap_i64 682 | i32.const 31 683 | i32.const 3 684 | local.get $6 685 | i64.const 2 686 | i64.and 687 | i64.const 0 688 | i64.ne 689 | select 690 | i32.and 691 | br_table $case0|20 $case1|20 $case2|20 $break|20 $break|20 $break|20 $case3|20 $break|20 $break|20 $break|20 $case4|20 $break|20 $break|20 $break|20 $case5|20 $break|20 $break|20 $break|20 $case6|20 $break|20 $break|20 $break|20 $case7|20 $break|20 $break|20 $break|20 $case8|20 $break|20 $break|20 $break|20 $case9|20 $break|20 692 | end 693 | local.get $1 694 | i32.const 5 695 | i32.shr_u 696 | i32.const 1023 697 | i32.and 698 | local.tee $7 699 | i32.const 1 700 | i32.shl 701 | i32.load16_u offset=2080 702 | local.set $12 703 | local.get $1 704 | i32.const 15 705 | i32.shr_u 706 | i32.const 1023 707 | i32.and 708 | local.tee $8 709 | i32.const 1 710 | i32.shl 711 | i32.load16_u offset=2080 712 | local.set $16 713 | local.get $6 714 | i64.const 25 715 | i64.shr_u 716 | i64.const 1023 717 | i64.and 718 | i32.wrap_i64 719 | local.tee $5 720 | i32.const 1 721 | i32.shl 722 | i32.load16_u offset=2080 723 | local.set $11 724 | local.get $7 725 | local.get $0 726 | i32.const 3 727 | i32.shr_u 728 | i32.const 27 729 | i32.shl 730 | i32.const 27 731 | i32.shr_s 732 | i32.add 733 | i32.const 1023 734 | i32.and 735 | i32.const 1 736 | i32.shl 737 | i32.load16_u offset=2080 738 | local.set $15 739 | local.get $8 740 | local.get $0 741 | i32.const 13 742 | i32.shr_u 743 | i32.const 27 744 | i32.shl 745 | i32.const 27 746 | i32.shr_s 747 | i32.add 748 | i32.const 1023 749 | i32.and 750 | i32.const 1 751 | i32.shl 752 | i32.load16_u offset=2080 753 | local.set $14 754 | local.get $5 755 | local.get $0 756 | i32.const 23 757 | i32.shr_u 758 | i32.const 27 759 | i32.shl 760 | i32.const 27 761 | i32.shr_s 762 | i32.add 763 | i32.const 1023 764 | i32.and 765 | i32.const 1 766 | i32.shl 767 | i32.load16_u offset=2080 768 | local.set $10 769 | local.get $7 770 | local.get $4 771 | i32.const 1 772 | i32.shr_u 773 | i32.const 27 774 | i32.shl 775 | i32.const 27 776 | i32.shr_s 777 | i32.add 778 | i32.const 1023 779 | i32.and 780 | i32.const 1 781 | i32.shl 782 | i32.load16_u offset=2080 783 | local.set $13 784 | local.get $8 785 | local.get $1 786 | i32.const 2 787 | i32.shl 788 | i32.const 16 789 | i32.and 790 | local.get $0 791 | i32.const 9 792 | i32.shr_u 793 | i32.const 15 794 | i32.and 795 | i32.or 796 | i32.const 27 797 | i32.shl 798 | i32.const 27 799 | i32.shr_s 800 | i32.add 801 | i32.const 1023 802 | i32.and 803 | i32.const 1 804 | i32.shl 805 | i32.load16_u offset=2080 806 | local.set $9 807 | local.get $5 808 | local.get $1 809 | i32.const 1 810 | i32.shl 811 | i32.const 16 812 | i32.and 813 | local.get $4 814 | i32.const 3 815 | i32.shl 816 | i32.const 8 817 | i32.and 818 | i32.or 819 | local.get $0 820 | i32.const 29 821 | i32.shr_u 822 | i32.or 823 | i32.const 27 824 | i32.shl 825 | i32.const 27 826 | i32.shr_s 827 | i32.add 828 | i32.const 1023 829 | i32.and 830 | i32.const 1 831 | i32.shl 832 | i32.load16_u offset=2080 833 | local.set $17 834 | local.get $7 835 | local.get $4 836 | i32.const 7 837 | i32.shr_u 838 | i32.const 27 839 | i32.shl 840 | i32.const 27 841 | i32.shr_s 842 | i32.add 843 | i32.const 1023 844 | i32.and 845 | i32.const 1 846 | i32.shl 847 | i32.load16_u offset=2080 848 | local.set $7 849 | local.get $8 850 | local.get $0 851 | i32.const 4 852 | i32.shr_u 853 | i32.const 16 854 | i32.and 855 | local.get $0 856 | i32.const 19 857 | i32.shr_u 858 | i32.const 15 859 | i32.and 860 | i32.or 861 | i32.const 27 862 | i32.shl 863 | i32.const 27 864 | i32.shr_s 865 | i32.add 866 | i32.const 1023 867 | i32.and 868 | i32.const 1 869 | i32.shl 870 | i32.load16_u offset=2080 871 | local.set $8 872 | local.get $5 873 | local.get $0 874 | i32.const 18 875 | i32.shr_u 876 | i32.const 1 877 | i32.and 878 | local.get $0 879 | i32.const 27 880 | i32.shr_u 881 | i32.const 2 882 | i32.and 883 | local.get $4 884 | i32.const 4 885 | i32.shr_u 886 | i32.const 4 887 | i32.and 888 | local.get $1 889 | i32.const 16 890 | i32.and 891 | local.get $4 892 | i32.const 9 893 | i32.shr_u 894 | i32.const 8 895 | i32.and 896 | i32.or 897 | i32.or 898 | i32.or 899 | i32.or 900 | i32.const 27 901 | i32.shl 902 | i32.const 27 903 | i32.shr_s 904 | i32.add 905 | i32.const 1023 906 | i32.and 907 | i32.const 1 908 | i32.shl 909 | i32.load16_u offset=2080 910 | local.set $5 911 | br $break|20 912 | end 913 | local.get $1 914 | i32.const 5 915 | i32.shr_u 916 | i32.const 127 917 | i32.and 918 | local.tee $7 919 | i32.const 1 920 | i32.shl 921 | i32.load16_u offset=288 922 | local.set $12 923 | local.get $1 924 | i32.const 15 925 | i32.shr_u 926 | i32.const 127 927 | i32.and 928 | local.tee $8 929 | i32.const 1 930 | i32.shl 931 | i32.load16_u offset=288 932 | local.set $16 933 | local.get $1 934 | i32.const 25 935 | i32.shr_u 936 | local.tee $5 937 | i32.const 1 938 | i32.shl 939 | i32.load16_u offset=288 940 | local.set $11 941 | local.get $7 942 | local.get $0 943 | i32.const 3 944 | i32.shr_u 945 | i32.const 26 946 | i32.shl 947 | i32.const 26 948 | i32.shr_s 949 | i32.add 950 | i32.const 127 951 | i32.and 952 | i32.const 1 953 | i32.shl 954 | i32.load16_u offset=288 955 | local.set $15 956 | local.get $8 957 | local.get $0 958 | i32.const 13 959 | i32.shr_u 960 | i32.const 26 961 | i32.shl 962 | i32.const 26 963 | i32.shr_s 964 | i32.add 965 | i32.const 127 966 | i32.and 967 | i32.const 1 968 | i32.shl 969 | i32.load16_u offset=288 970 | local.set $14 971 | local.get $5 972 | local.get $0 973 | i32.const 23 974 | i32.shr_u 975 | i32.const 26 976 | i32.shl 977 | i32.const 26 978 | i32.shr_s 979 | i32.add 980 | i32.const 127 981 | i32.and 982 | i32.const 1 983 | i32.shl 984 | i32.load16_u offset=288 985 | local.set $10 986 | local.get $7 987 | local.get $4 988 | i32.const 1 989 | i32.shr_u 990 | i32.const 26 991 | i32.shl 992 | i32.const 26 993 | i32.shr_s 994 | i32.add 995 | i32.const 127 996 | i32.and 997 | i32.const 1 998 | i32.shl 999 | i32.load16_u offset=288 1000 | local.set $13 1001 | local.get $8 1002 | local.get $0 1003 | i32.const 9 1004 | i32.shr_u 1005 | i32.const 15 1006 | i32.and 1007 | local.get $1 1008 | i32.const 3 1009 | i32.shl 1010 | i32.const 32 1011 | i32.and 1012 | local.get $1 1013 | i32.const 20 1014 | i32.shr_u 1015 | i32.const 16 1016 | i32.and 1017 | i32.or 1018 | i32.or 1019 | i32.const 26 1020 | i32.shl 1021 | i32.const 26 1022 | i32.shr_s 1023 | i32.add 1024 | i32.const 127 1025 | i32.and 1026 | i32.const 1 1027 | i32.shl 1028 | i32.load16_u offset=288 1029 | local.set $9 1030 | local.get $5 1031 | local.get $4 1032 | i32.const 3 1033 | i32.shl 1034 | i32.const 8 1035 | i32.and 1036 | local.get $1 1037 | i32.const 17 1038 | i32.shr_u 1039 | i32.const 32 1040 | i32.and 1041 | local.get $1 1042 | i32.const 10 1043 | i32.shr_u 1044 | i32.const 16 1045 | i32.and 1046 | i32.or 1047 | i32.or 1048 | local.get $0 1049 | i32.const 29 1050 | i32.shr_u 1051 | i32.or 1052 | i32.const 26 1053 | i32.shl 1054 | i32.const 26 1055 | i32.shr_s 1056 | i32.add 1057 | i32.const 127 1058 | i32.and 1059 | i32.const 1 1060 | i32.shl 1061 | i32.load16_u offset=288 1062 | local.set $17 1063 | local.get $7 1064 | local.get $4 1065 | i32.const 7 1066 | i32.shr_u 1067 | i32.const 26 1068 | i32.shl 1069 | i32.const 26 1070 | i32.shr_s 1071 | i32.add 1072 | i32.const 127 1073 | i32.and 1074 | i32.const 1 1075 | i32.shl 1076 | i32.load16_u offset=288 1077 | local.set $7 1078 | local.get $8 1079 | local.get $1 1080 | i32.const 1 1081 | i32.shl 1082 | i32.const 48 1083 | i32.and 1084 | local.get $0 1085 | i32.const 19 1086 | i32.shr_u 1087 | i32.const 15 1088 | i32.and 1089 | i32.or 1090 | i32.const 26 1091 | i32.shl 1092 | i32.const 26 1093 | i32.shr_s 1094 | i32.add 1095 | i32.const 127 1096 | i32.and 1097 | i32.const 1 1098 | i32.shl 1099 | i32.load16_u offset=288 1100 | local.set $8 1101 | local.get $5 1102 | local.get $1 1103 | i32.const 12 1104 | i32.shr_u 1105 | i32.const 3 1106 | i32.and 1107 | local.get $1 1108 | i32.const 21 1109 | i32.shr_u 1110 | i32.const 4 1111 | i32.and 1112 | local.get $0 1113 | i32.const 3 1114 | i32.shl 1115 | i32.const 8 1116 | i32.and 1117 | local.get $0 1118 | i32.const 4 1119 | i32.shl 1120 | i32.const 32 1121 | i32.and 1122 | local.get $0 1123 | i32.const 2 1124 | i32.shl 1125 | i32.const 16 1126 | i32.and 1127 | i32.or 1128 | i32.or 1129 | i32.or 1130 | i32.or 1131 | i32.const 26 1132 | i32.shl 1133 | i32.const 26 1134 | i32.shr_s 1135 | i32.add 1136 | i32.const 127 1137 | i32.and 1138 | i32.const 1 1139 | i32.shl 1140 | i32.load16_u offset=288 1141 | local.set $5 1142 | br $break|20 1143 | end 1144 | local.get $0 1145 | i32.const 2 1146 | i32.shl 1147 | i32.const 1024 1148 | i32.and 1149 | local.get $1 1150 | i32.const 5 1151 | i32.shr_u 1152 | i32.const 1023 1153 | i32.and 1154 | i32.or 1155 | local.tee $7 1156 | i32.const 1 1157 | i32.shl 1158 | i32.load16_u offset=4128 1159 | local.set $12 1160 | local.get $0 1161 | i32.const 7 1162 | i32.shr_u 1163 | i32.const 1024 1164 | i32.and 1165 | local.get $1 1166 | i32.const 15 1167 | i32.shr_u 1168 | i32.const 1023 1169 | i32.and 1170 | i32.or 1171 | local.tee $1 1172 | i32.const 1 1173 | i32.shl 1174 | i32.load16_u offset=4128 1175 | local.set $16 1176 | local.get $6 1177 | i64.const 25 1178 | i64.shr_u 1179 | i64.const 1023 1180 | i64.and 1181 | i32.wrap_i64 1182 | local.get $0 1183 | i32.const 17 1184 | i32.shr_u 1185 | i32.const 1024 1186 | i32.and 1187 | i32.or 1188 | local.tee $5 1189 | i32.const 1 1190 | i32.shl 1191 | i32.load16_u offset=4128 1192 | local.set $11 1193 | local.get $7 1194 | local.get $0 1195 | i32.const 3 1196 | i32.shr_u 1197 | i32.const 27 1198 | i32.shl 1199 | i32.const 27 1200 | i32.shr_s 1201 | i32.add 1202 | i32.const 2047 1203 | i32.and 1204 | i32.const 1 1205 | i32.shl 1206 | i32.load16_u offset=4128 1207 | local.set $15 1208 | local.get $1 1209 | local.get $0 1210 | i32.const 13 1211 | i32.shr_u 1212 | i32.const 28 1213 | i32.shl 1214 | i32.const 28 1215 | i32.shr_s 1216 | i32.add 1217 | i32.const 2047 1218 | i32.and 1219 | i32.const 1 1220 | i32.shl 1221 | i32.load16_u offset=4128 1222 | local.set $14 1223 | local.get $5 1224 | local.get $0 1225 | i32.const 23 1226 | i32.shr_u 1227 | i32.const 28 1228 | i32.shl 1229 | i32.const 28 1230 | i32.shr_s 1231 | i32.add 1232 | i32.const 2047 1233 | i32.and 1234 | i32.const 1 1235 | i32.shl 1236 | i32.load16_u offset=4128 1237 | local.set $10 1238 | local.get $7 1239 | local.get $4 1240 | i32.const 1 1241 | i32.shr_u 1242 | i32.const 27 1243 | i32.shl 1244 | i32.const 27 1245 | i32.shr_s 1246 | i32.add 1247 | i32.const 2047 1248 | i32.and 1249 | i32.const 1 1250 | i32.shl 1251 | i32.load16_u offset=4128 1252 | local.set $13 1253 | local.get $1 1254 | local.get $0 1255 | i32.const 9 1256 | i32.shr_u 1257 | i32.const 28 1258 | i32.shl 1259 | i32.const 28 1260 | i32.shr_s 1261 | i32.add 1262 | i32.const 2047 1263 | i32.and 1264 | i32.const 1 1265 | i32.shl 1266 | i32.load16_u offset=4128 1267 | local.set $9 1268 | local.get $5 1269 | local.get $4 1270 | i32.const 3 1271 | i32.shl 1272 | i32.const 8 1273 | i32.and 1274 | local.get $0 1275 | i32.const 29 1276 | i32.shr_u 1277 | i32.or 1278 | i32.const 28 1279 | i32.shl 1280 | i32.const 28 1281 | i32.shr_s 1282 | i32.add 1283 | i32.const 2047 1284 | i32.and 1285 | i32.const 1 1286 | i32.shl 1287 | i32.load16_u offset=4128 1288 | local.set $17 1289 | local.get $7 1290 | local.get $4 1291 | i32.const 7 1292 | i32.shr_u 1293 | i32.const 27 1294 | i32.shl 1295 | i32.const 27 1296 | i32.shr_s 1297 | i32.add 1298 | i32.const 2047 1299 | i32.and 1300 | i32.const 1 1301 | i32.shl 1302 | i32.load16_u offset=4128 1303 | local.set $7 1304 | local.get $1 1305 | local.get $0 1306 | i32.const 19 1307 | i32.shr_u 1308 | i32.const 28 1309 | i32.shl 1310 | i32.const 28 1311 | i32.shr_s 1312 | i32.add 1313 | i32.const 2047 1314 | i32.and 1315 | i32.const 1 1316 | i32.shl 1317 | i32.load16_u offset=4128 1318 | local.set $8 1319 | local.get $5 1320 | local.get $0 1321 | i32.const 18 1322 | i32.shr_u 1323 | i32.const 1 1324 | i32.and 1325 | local.get $0 1326 | i32.const 27 1327 | i32.shr_u 1328 | i32.const 2 1329 | i32.and 1330 | local.get $4 1331 | i32.const 9 1332 | i32.shr_u 1333 | i32.const 8 1334 | i32.and 1335 | local.get $4 1336 | i32.const 4 1337 | i32.shr_u 1338 | i32.const 4 1339 | i32.and 1340 | i32.or 1341 | i32.or 1342 | i32.or 1343 | i32.const 28 1344 | i32.shl 1345 | i32.const 28 1346 | i32.shr_s 1347 | i32.add 1348 | i32.const 2047 1349 | i32.and 1350 | i32.const 1 1351 | i32.shl 1352 | i32.load16_u offset=4128 1353 | local.set $5 1354 | br $break|20 1355 | end 1356 | local.get $6 1357 | i64.const 29 1358 | i64.shr_u 1359 | i64.const 1024 1360 | i64.and 1361 | local.get $6 1362 | i64.const 5 1363 | i64.shr_u 1364 | i64.const 1023 1365 | i64.and 1366 | i64.or 1367 | i32.wrap_i64 1368 | local.tee $1 1369 | i32.const 1 1370 | i32.shl 1371 | i32.load16_u offset=4128 1372 | local.set $12 1373 | local.get $6 1374 | i64.const 40 1375 | i64.shr_u 1376 | i64.const 1024 1377 | i64.and 1378 | local.get $6 1379 | i64.const 15 1380 | i64.shr_u 1381 | i64.const 1023 1382 | i64.and 1383 | i64.or 1384 | i32.wrap_i64 1385 | local.tee $8 1386 | i32.const 1 1387 | i32.shl 1388 | i32.load16_u offset=4128 1389 | local.set $16 1390 | local.get $6 1391 | i64.const 49 1392 | i64.shr_u 1393 | i64.const 1024 1394 | i64.and 1395 | local.get $6 1396 | i64.const 25 1397 | i64.shr_u 1398 | i64.const 1023 1399 | i64.and 1400 | i64.or 1401 | i32.wrap_i64 1402 | local.tee $5 1403 | i32.const 1 1404 | i32.shl 1405 | i32.load16_u offset=4128 1406 | local.set $11 1407 | local.get $1 1408 | local.get $0 1409 | i32.const 3 1410 | i32.shr_u 1411 | i32.const 28 1412 | i32.shl 1413 | i32.const 28 1414 | i32.shr_s 1415 | i32.add 1416 | i32.const 2047 1417 | i32.and 1418 | i32.const 1 1419 | i32.shl 1420 | i32.load16_u offset=4128 1421 | local.set $15 1422 | local.get $8 1423 | local.get $0 1424 | i32.const 13 1425 | i32.shr_u 1426 | i32.const 27 1427 | i32.shl 1428 | i32.const 27 1429 | i32.shr_s 1430 | i32.add 1431 | i32.const 2047 1432 | i32.and 1433 | i32.const 1 1434 | i32.shl 1435 | i32.load16_u offset=4128 1436 | local.set $14 1437 | local.get $5 1438 | local.get $0 1439 | i32.const 23 1440 | i32.shr_u 1441 | i32.const 28 1442 | i32.shl 1443 | i32.const 28 1444 | i32.shr_s 1445 | i32.add 1446 | i32.const 2047 1447 | i32.and 1448 | i32.const 1 1449 | i32.shl 1450 | i32.load16_u offset=4128 1451 | local.set $10 1452 | local.get $1 1453 | local.get $4 1454 | i32.const 1 1455 | i32.shr_u 1456 | i32.const 28 1457 | i32.shl 1458 | i32.const 28 1459 | i32.shr_s 1460 | i32.add 1461 | i32.const 2047 1462 | i32.and 1463 | i32.const 1 1464 | i32.shl 1465 | i32.load16_u offset=4128 1466 | local.set $13 1467 | local.get $8 1468 | local.get $4 1469 | i32.const 7 1470 | i32.shr_u 1471 | local.tee $7 1472 | i32.const 16 1473 | i32.and 1474 | local.get $0 1475 | i32.const 9 1476 | i32.shr_u 1477 | i32.const 15 1478 | i32.and 1479 | i32.or 1480 | i32.const 27 1481 | i32.shl 1482 | i32.const 27 1483 | i32.shr_s 1484 | i32.add 1485 | i32.const 2047 1486 | i32.and 1487 | i32.const 1 1488 | i32.shl 1489 | i32.load16_u offset=4128 1490 | local.set $9 1491 | local.get $5 1492 | local.get $4 1493 | i32.const 3 1494 | i32.shl 1495 | i32.const 8 1496 | i32.and 1497 | local.get $0 1498 | i32.const 29 1499 | i32.shr_u 1500 | i32.or 1501 | i32.const 28 1502 | i32.shl 1503 | i32.const 28 1504 | i32.shr_s 1505 | i32.add 1506 | i32.const 2047 1507 | i32.and 1508 | i32.const 1 1509 | i32.shl 1510 | i32.load16_u offset=4128 1511 | local.set $17 1512 | local.get $1 1513 | local.get $7 1514 | i32.const 28 1515 | i32.shl 1516 | i32.const 28 1517 | i32.shr_s 1518 | i32.add 1519 | i32.const 2047 1520 | i32.and 1521 | i32.const 1 1522 | i32.shl 1523 | i32.load16_u offset=4128 1524 | local.set $7 1525 | local.get $8 1526 | local.get $0 1527 | i32.const 4 1528 | i32.shr_u 1529 | i32.const 16 1530 | i32.and 1531 | local.get $0 1532 | i32.const 19 1533 | i32.shr_u 1534 | i32.const 15 1535 | i32.and 1536 | i32.or 1537 | i32.const 27 1538 | i32.shl 1539 | i32.const 27 1540 | i32.shr_s 1541 | i32.add 1542 | i32.const 2047 1543 | i32.and 1544 | i32.const 1 1545 | i32.shl 1546 | i32.load16_u offset=4128 1547 | local.set $8 1548 | local.get $5 1549 | local.get $4 1550 | i32.const 5 1551 | i32.shr_u 1552 | i32.const 1 1553 | i32.and 1554 | local.get $0 1555 | i32.const 27 1556 | i32.shr_u 1557 | i32.const 2 1558 | i32.and 1559 | local.get $4 1560 | i32.const 9 1561 | i32.shr_u 1562 | i32.const 8 1563 | i32.and 1564 | local.get $4 1565 | i32.const 4 1566 | i32.shr_u 1567 | i32.const 4 1568 | i32.and 1569 | i32.or 1570 | i32.or 1571 | i32.or 1572 | i32.const 28 1573 | i32.shl 1574 | i32.const 28 1575 | i32.shr_s 1576 | i32.add 1577 | i32.const 2047 1578 | i32.and 1579 | i32.const 1 1580 | i32.shl 1581 | i32.load16_u offset=4128 1582 | local.set $5 1583 | br $break|20 1584 | end 1585 | local.get $0 1586 | i32.const 3 1587 | i32.shl 1588 | i32.const 1024 1589 | i32.and 1590 | local.get $1 1591 | i32.const 5 1592 | i32.shr_u 1593 | i32.const 1023 1594 | i32.and 1595 | i32.or 1596 | local.tee $7 1597 | i32.const 1 1598 | i32.shl 1599 | i32.load16_u offset=4128 1600 | local.set $12 1601 | local.get $0 1602 | i32.const 7 1603 | i32.shr_u 1604 | i32.const 1024 1605 | i32.and 1606 | local.get $1 1607 | i32.const 15 1608 | i32.shr_u 1609 | i32.const 1023 1610 | i32.and 1611 | i32.or 1612 | local.tee $1 1613 | i32.const 1 1614 | i32.shl 1615 | i32.load16_u offset=4128 1616 | local.set $16 1617 | local.get $6 1618 | i64.const 25 1619 | i64.shr_u 1620 | i64.const 1023 1621 | i64.and 1622 | i32.wrap_i64 1623 | local.get $0 1624 | i32.const 18 1625 | i32.shr_u 1626 | local.tee $19 1627 | i32.const 1024 1628 | i32.and 1629 | i32.or 1630 | local.tee $5 1631 | i32.const 1 1632 | i32.shl 1633 | i32.load16_u offset=4128 1634 | local.set $11 1635 | local.get $7 1636 | local.get $0 1637 | i32.const 3 1638 | i32.shr_u 1639 | i32.const 28 1640 | i32.shl 1641 | i32.const 28 1642 | i32.shr_s 1643 | i32.add 1644 | i32.const 2047 1645 | i32.and 1646 | i32.const 1 1647 | i32.shl 1648 | i32.load16_u offset=4128 1649 | local.set $15 1650 | local.get $1 1651 | local.get $0 1652 | i32.const 13 1653 | i32.shr_u 1654 | i32.const 28 1655 | i32.shl 1656 | i32.const 28 1657 | i32.shr_s 1658 | i32.add 1659 | i32.const 2047 1660 | i32.and 1661 | i32.const 1 1662 | i32.shl 1663 | i32.load16_u offset=4128 1664 | local.set $14 1665 | local.get $5 1666 | local.get $0 1667 | i32.const 23 1668 | i32.shr_u 1669 | i32.const 27 1670 | i32.shl 1671 | i32.const 27 1672 | i32.shr_s 1673 | i32.add 1674 | i32.const 2047 1675 | i32.and 1676 | i32.const 1 1677 | i32.shl 1678 | i32.load16_u offset=4128 1679 | local.set $10 1680 | local.get $7 1681 | local.get $4 1682 | i32.const 1 1683 | i32.shr_u 1684 | i32.const 28 1685 | i32.shl 1686 | i32.const 28 1687 | i32.shr_s 1688 | i32.add 1689 | i32.const 2047 1690 | i32.and 1691 | i32.const 1 1692 | i32.shl 1693 | i32.load16_u offset=4128 1694 | local.set $13 1695 | local.get $1 1696 | local.get $0 1697 | i32.const 9 1698 | i32.shr_u 1699 | i32.const 28 1700 | i32.shl 1701 | i32.const 28 1702 | i32.shr_s 1703 | i32.add 1704 | i32.const 2047 1705 | i32.and 1706 | i32.const 1 1707 | i32.shl 1708 | i32.load16_u offset=4128 1709 | local.set $9 1710 | local.get $5 1711 | local.get $0 1712 | i32.const 4 1713 | i32.shr_u 1714 | i32.const 16 1715 | i32.and 1716 | local.get $4 1717 | i32.const 3 1718 | i32.shl 1719 | i32.const 8 1720 | i32.and 1721 | i32.or 1722 | local.get $0 1723 | i32.const 29 1724 | i32.shr_u 1725 | i32.or 1726 | i32.const 27 1727 | i32.shl 1728 | i32.const 27 1729 | i32.shr_s 1730 | i32.add 1731 | i32.const 2047 1732 | i32.and 1733 | i32.const 1 1734 | i32.shl 1735 | i32.load16_u offset=4128 1736 | local.set $17 1737 | local.get $7 1738 | local.get $4 1739 | i32.const 7 1740 | i32.shr_u 1741 | local.tee $20 1742 | i32.const 28 1743 | i32.shl 1744 | i32.const 28 1745 | i32.shr_s 1746 | i32.add 1747 | i32.const 2047 1748 | i32.and 1749 | i32.const 1 1750 | i32.shl 1751 | i32.load16_u offset=4128 1752 | local.set $7 1753 | local.get $1 1754 | local.get $0 1755 | i32.const 19 1756 | i32.shr_u 1757 | i32.const 28 1758 | i32.shl 1759 | i32.const 28 1760 | i32.shr_s 1761 | i32.add 1762 | i32.const 2047 1763 | i32.and 1764 | i32.const 1 1765 | i32.shl 1766 | i32.load16_u offset=4128 1767 | local.set $8 1768 | local.get $5 1769 | local.get $19 1770 | i32.const 1 1771 | i32.and 1772 | local.get $4 1773 | i32.const 4 1774 | i32.shr_u 1775 | i32.const 6 1776 | i32.and 1777 | local.get $20 1778 | i32.const 16 1779 | i32.and 1780 | local.get $4 1781 | i32.const 9 1782 | i32.shr_u 1783 | i32.const 8 1784 | i32.and 1785 | i32.or 1786 | i32.or 1787 | i32.or 1788 | i32.const 27 1789 | i32.shl 1790 | i32.const 27 1791 | i32.shr_s 1792 | i32.add 1793 | i32.const 2047 1794 | i32.and 1795 | i32.const 1 1796 | i32.shl 1797 | i32.load16_u offset=4128 1798 | local.set $5 1799 | br $break|20 1800 | end 1801 | local.get $1 1802 | i32.const 5 1803 | i32.shr_u 1804 | i32.const 511 1805 | i32.and 1806 | local.tee $7 1807 | i32.const 1 1808 | i32.shl 1809 | i32.load16_u offset=1056 1810 | local.set $12 1811 | local.get $1 1812 | i32.const 15 1813 | i32.shr_u 1814 | i32.const 511 1815 | i32.and 1816 | local.tee $8 1817 | i32.const 1 1818 | i32.shl 1819 | i32.load16_u offset=1056 1820 | local.set $16 1821 | local.get $6 1822 | i64.const 25 1823 | i64.shr_u 1824 | i64.const 511 1825 | i64.and 1826 | i32.wrap_i64 1827 | local.tee $5 1828 | i32.const 1 1829 | i32.shl 1830 | i32.load16_u offset=1056 1831 | local.set $11 1832 | local.get $7 1833 | local.get $0 1834 | i32.const 3 1835 | i32.shr_u 1836 | i32.const 27 1837 | i32.shl 1838 | i32.const 27 1839 | i32.shr_s 1840 | i32.add 1841 | i32.const 511 1842 | i32.and 1843 | i32.const 1 1844 | i32.shl 1845 | i32.load16_u offset=1056 1846 | local.set $15 1847 | local.get $8 1848 | local.get $0 1849 | i32.const 13 1850 | i32.shr_u 1851 | i32.const 27 1852 | i32.shl 1853 | i32.const 27 1854 | i32.shr_s 1855 | i32.add 1856 | i32.const 511 1857 | i32.and 1858 | i32.const 1 1859 | i32.shl 1860 | i32.load16_u offset=1056 1861 | local.set $14 1862 | local.get $5 1863 | local.get $0 1864 | i32.const 23 1865 | i32.shr_u 1866 | i32.const 27 1867 | i32.shl 1868 | i32.const 27 1869 | i32.shr_s 1870 | i32.add 1871 | i32.const 511 1872 | i32.and 1873 | i32.const 1 1874 | i32.shl 1875 | i32.load16_u offset=1056 1876 | local.set $10 1877 | local.get $7 1878 | local.get $4 1879 | i32.const 1 1880 | i32.shr_u 1881 | i32.const 27 1882 | i32.shl 1883 | i32.const 27 1884 | i32.shr_s 1885 | i32.add 1886 | i32.const 511 1887 | i32.and 1888 | i32.const 1 1889 | i32.shl 1890 | i32.load16_u offset=1056 1891 | local.set $13 1892 | local.get $8 1893 | local.get $1 1894 | i32.const 20 1895 | i32.shr_u 1896 | i32.const 16 1897 | i32.and 1898 | local.get $0 1899 | i32.const 9 1900 | i32.shr_u 1901 | i32.const 15 1902 | i32.and 1903 | i32.or 1904 | i32.const 27 1905 | i32.shl 1906 | i32.const 27 1907 | i32.shr_s 1908 | i32.add 1909 | i32.const 511 1910 | i32.and 1911 | i32.const 1 1912 | i32.shl 1913 | i32.load16_u offset=1056 1914 | local.set $9 1915 | local.get $5 1916 | local.get $1 1917 | i32.const 10 1918 | i32.shr_u 1919 | i32.const 16 1920 | i32.and 1921 | local.get $4 1922 | i32.const 3 1923 | i32.shl 1924 | i32.const 8 1925 | i32.and 1926 | i32.or 1927 | local.get $0 1928 | i32.const 29 1929 | i32.shr_u 1930 | i32.or 1931 | i32.const 27 1932 | i32.shl 1933 | i32.const 27 1934 | i32.shr_s 1935 | i32.add 1936 | i32.const 511 1937 | i32.and 1938 | i32.const 1 1939 | i32.shl 1940 | i32.load16_u offset=1056 1941 | local.set $17 1942 | local.get $7 1943 | local.get $4 1944 | i32.const 7 1945 | i32.shr_u 1946 | i32.const 27 1947 | i32.shl 1948 | i32.const 27 1949 | i32.shr_s 1950 | i32.add 1951 | i32.const 511 1952 | i32.and 1953 | i32.const 1 1954 | i32.shl 1955 | i32.load16_u offset=1056 1956 | local.set $7 1957 | local.get $8 1958 | local.get $0 1959 | i32.const 4 1960 | i32.shr_u 1961 | i32.const 16 1962 | i32.and 1963 | local.get $0 1964 | i32.const 19 1965 | i32.shr_u 1966 | i32.const 15 1967 | i32.and 1968 | i32.or 1969 | i32.const 27 1970 | i32.shl 1971 | i32.const 27 1972 | i32.shr_s 1973 | i32.add 1974 | i32.const 511 1975 | i32.and 1976 | i32.const 1 1977 | i32.shl 1978 | i32.load16_u offset=1056 1979 | local.set $8 1980 | local.get $5 1981 | local.get $0 1982 | i32.const 18 1983 | i32.shr_u 1984 | i32.const 1 1985 | i32.and 1986 | local.get $0 1987 | i32.const 27 1988 | i32.shr_u 1989 | i32.const 2 1990 | i32.and 1991 | local.get $4 1992 | i32.const 4 1993 | i32.shr_u 1994 | i32.const 4 1995 | i32.and 1996 | local.get $0 1997 | i32.const 2 1998 | i32.shl 1999 | i32.const 16 2000 | i32.and 2001 | local.get $4 2002 | i32.const 9 2003 | i32.shr_u 2004 | i32.const 8 2005 | i32.and 2006 | i32.or 2007 | i32.or 2008 | i32.or 2009 | i32.or 2010 | i32.const 27 2011 | i32.shl 2012 | i32.const 27 2013 | i32.shr_s 2014 | i32.add 2015 | i32.const 511 2016 | i32.and 2017 | i32.const 1 2018 | i32.shl 2019 | i32.load16_u offset=1056 2020 | local.set $5 2021 | br $break|20 2022 | end 2023 | local.get $1 2024 | i32.const 5 2025 | i32.shr_u 2026 | i32.const 255 2027 | i32.and 2028 | local.tee $7 2029 | i32.const 1 2030 | i32.shl 2031 | i32.load16_u offset=544 2032 | local.set $12 2033 | local.get $1 2034 | i32.const 15 2035 | i32.shr_u 2036 | i32.const 255 2037 | i32.and 2038 | local.tee $8 2039 | i32.const 1 2040 | i32.shl 2041 | i32.load16_u offset=544 2042 | local.set $16 2043 | local.get $6 2044 | i64.const 25 2045 | i64.shr_u 2046 | i64.const 255 2047 | i64.and 2048 | i32.wrap_i64 2049 | local.tee $5 2050 | i32.const 1 2051 | i32.shl 2052 | i32.load16_u offset=544 2053 | local.set $11 2054 | local.get $7 2055 | local.get $0 2056 | i32.const 3 2057 | i32.shr_u 2058 | i32.const 26 2059 | i32.shl 2060 | i32.const 26 2061 | i32.shr_s 2062 | i32.add 2063 | i32.const 255 2064 | i32.and 2065 | i32.const 1 2066 | i32.shl 2067 | i32.load16_u offset=544 2068 | local.set $15 2069 | local.get $8 2070 | local.get $0 2071 | i32.const 13 2072 | i32.shr_u 2073 | i32.const 27 2074 | i32.shl 2075 | i32.const 27 2076 | i32.shr_s 2077 | i32.add 2078 | i32.const 255 2079 | i32.and 2080 | i32.const 1 2081 | i32.shl 2082 | i32.load16_u offset=544 2083 | local.set $14 2084 | local.get $5 2085 | local.get $0 2086 | i32.const 23 2087 | i32.shr_u 2088 | i32.const 27 2089 | i32.shl 2090 | i32.const 27 2091 | i32.shr_s 2092 | i32.add 2093 | i32.const 255 2094 | i32.and 2095 | i32.const 1 2096 | i32.shl 2097 | i32.load16_u offset=544 2098 | local.set $10 2099 | local.get $7 2100 | local.get $4 2101 | i32.const 1 2102 | i32.shr_u 2103 | i32.const 26 2104 | i32.shl 2105 | i32.const 26 2106 | i32.shr_s 2107 | i32.add 2108 | i32.const 255 2109 | i32.and 2110 | i32.const 1 2111 | i32.shl 2112 | i32.load16_u offset=544 2113 | local.set $13 2114 | local.get $8 2115 | local.get $1 2116 | i32.const 20 2117 | i32.shr_u 2118 | i32.const 16 2119 | i32.and 2120 | local.get $0 2121 | i32.const 9 2122 | i32.shr_u 2123 | i32.const 15 2124 | i32.and 2125 | i32.or 2126 | i32.const 27 2127 | i32.shl 2128 | i32.const 27 2129 | i32.shr_s 2130 | i32.add 2131 | i32.const 255 2132 | i32.and 2133 | i32.const 1 2134 | i32.shl 2135 | i32.load16_u offset=544 2136 | local.set $9 2137 | local.get $5 2138 | local.get $1 2139 | i32.const 10 2140 | i32.shr_u 2141 | i32.const 16 2142 | i32.and 2143 | local.get $4 2144 | i32.const 3 2145 | i32.shl 2146 | i32.const 8 2147 | i32.and 2148 | i32.or 2149 | local.get $0 2150 | i32.const 29 2151 | i32.shr_u 2152 | i32.or 2153 | i32.const 27 2154 | i32.shl 2155 | i32.const 27 2156 | i32.shr_s 2157 | i32.add 2158 | i32.const 255 2159 | i32.and 2160 | i32.const 1 2161 | i32.shl 2162 | i32.load16_u offset=544 2163 | local.set $17 2164 | local.get $7 2165 | local.get $4 2166 | i32.const 7 2167 | i32.shr_u 2168 | i32.const 26 2169 | i32.shl 2170 | i32.const 26 2171 | i32.shr_s 2172 | i32.add 2173 | i32.const 255 2174 | i32.and 2175 | i32.const 1 2176 | i32.shl 2177 | i32.load16_u offset=544 2178 | local.set $7 2179 | local.get $8 2180 | local.get $1 2181 | i32.const 9 2182 | i32.shr_u 2183 | i32.const 16 2184 | i32.and 2185 | local.get $0 2186 | i32.const 19 2187 | i32.shr_u 2188 | i32.const 15 2189 | i32.and 2190 | i32.or 2191 | i32.const 27 2192 | i32.shl 2193 | i32.const 27 2194 | i32.shr_s 2195 | i32.add 2196 | i32.const 255 2197 | i32.and 2198 | i32.const 1 2199 | i32.shl 2200 | i32.load16_u offset=544 2201 | local.set $8 2202 | local.get $5 2203 | local.get $0 2204 | i32.const 18 2205 | i32.shr_u 2206 | i32.const 1 2207 | i32.and 2208 | local.get $0 2209 | i32.const 27 2210 | i32.shr_u 2211 | i32.const 2 2212 | i32.and 2213 | local.get $0 2214 | i32.const 2 2215 | i32.shl 2216 | i32.const 24 2217 | i32.and 2218 | local.get $1 2219 | i32.const 21 2220 | i32.shr_u 2221 | i32.const 4 2222 | i32.and 2223 | i32.or 2224 | i32.or 2225 | i32.or 2226 | i32.const 27 2227 | i32.shl 2228 | i32.const 27 2229 | i32.shr_s 2230 | i32.add 2231 | i32.const 255 2232 | i32.and 2233 | i32.const 1 2234 | i32.shl 2235 | i32.load16_u offset=544 2236 | local.set $5 2237 | br $break|20 2238 | end 2239 | local.get $1 2240 | i32.const 5 2241 | i32.shr_u 2242 | i32.const 255 2243 | i32.and 2244 | local.tee $7 2245 | i32.const 1 2246 | i32.shl 2247 | i32.load16_u offset=544 2248 | local.set $12 2249 | local.get $1 2250 | i32.const 15 2251 | i32.shr_u 2252 | i32.const 255 2253 | i32.and 2254 | local.tee $8 2255 | i32.const 1 2256 | i32.shl 2257 | i32.load16_u offset=544 2258 | local.set $16 2259 | local.get $6 2260 | i64.const 25 2261 | i64.shr_u 2262 | i64.const 255 2263 | i64.and 2264 | i32.wrap_i64 2265 | local.tee $5 2266 | i32.const 1 2267 | i32.shl 2268 | i32.load16_u offset=544 2269 | local.set $11 2270 | local.get $7 2271 | local.get $0 2272 | i32.const 3 2273 | i32.shr_u 2274 | i32.const 27 2275 | i32.shl 2276 | i32.const 27 2277 | i32.shr_s 2278 | i32.add 2279 | i32.const 255 2280 | i32.and 2281 | i32.const 1 2282 | i32.shl 2283 | i32.load16_u offset=544 2284 | local.set $15 2285 | local.get $8 2286 | local.get $0 2287 | i32.const 13 2288 | i32.shr_u 2289 | i32.const 26 2290 | i32.shl 2291 | i32.const 26 2292 | i32.shr_s 2293 | i32.add 2294 | i32.const 255 2295 | i32.and 2296 | i32.const 1 2297 | i32.shl 2298 | i32.load16_u offset=544 2299 | local.set $14 2300 | local.get $5 2301 | local.get $0 2302 | i32.const 23 2303 | i32.shr_u 2304 | i32.const 27 2305 | i32.shl 2306 | i32.const 27 2307 | i32.shr_s 2308 | i32.add 2309 | i32.const 255 2310 | i32.and 2311 | i32.const 1 2312 | i32.shl 2313 | i32.load16_u offset=544 2314 | local.set $10 2315 | local.get $7 2316 | local.get $4 2317 | i32.const 1 2318 | i32.shr_u 2319 | i32.const 27 2320 | i32.shl 2321 | i32.const 27 2322 | i32.shr_s 2323 | i32.add 2324 | i32.const 255 2325 | i32.and 2326 | i32.const 1 2327 | i32.shl 2328 | i32.load16_u offset=544 2329 | local.set $13 2330 | local.get $8 2331 | local.get $0 2332 | i32.const 9 2333 | i32.shr_u 2334 | i32.const 15 2335 | i32.and 2336 | local.get $1 2337 | i32.const 18 2338 | i32.shr_u 2339 | i32.const 32 2340 | i32.and 2341 | local.get $1 2342 | i32.const 20 2343 | i32.shr_u 2344 | i32.const 16 2345 | i32.and 2346 | i32.or 2347 | i32.or 2348 | i32.const 26 2349 | i32.shl 2350 | i32.const 26 2351 | i32.shr_s 2352 | i32.add 2353 | i32.const 255 2354 | i32.and 2355 | i32.const 1 2356 | i32.shl 2357 | i32.load16_u offset=544 2358 | local.set $9 2359 | local.get $5 2360 | local.get $1 2361 | i32.const 10 2362 | i32.shr_u 2363 | i32.const 16 2364 | i32.and 2365 | local.get $4 2366 | i32.const 3 2367 | i32.shl 2368 | i32.const 8 2369 | i32.and 2370 | i32.or 2371 | local.get $0 2372 | i32.const 29 2373 | i32.shr_u 2374 | i32.or 2375 | i32.const 27 2376 | i32.shl 2377 | i32.const 27 2378 | i32.shr_s 2379 | i32.add 2380 | i32.const 255 2381 | i32.and 2382 | i32.const 1 2383 | i32.shl 2384 | i32.load16_u offset=544 2385 | local.set $17 2386 | local.get $7 2387 | local.get $4 2388 | i32.const 7 2389 | i32.shr_u 2390 | i32.const 27 2391 | i32.shl 2392 | i32.const 27 2393 | i32.shr_s 2394 | i32.add 2395 | i32.const 255 2396 | i32.and 2397 | i32.const 1 2398 | i32.shl 2399 | i32.load16_u offset=544 2400 | local.set $7 2401 | local.get $8 2402 | local.get $0 2403 | i32.const 19 2404 | i32.shr_u 2405 | i32.const 15 2406 | i32.and 2407 | local.get $0 2408 | i32.const 4 2409 | i32.shl 2410 | i32.const 32 2411 | i32.and 2412 | local.get $0 2413 | i32.const 4 2414 | i32.shr_u 2415 | i32.const 16 2416 | i32.and 2417 | i32.or 2418 | i32.or 2419 | i32.const 26 2420 | i32.shl 2421 | i32.const 26 2422 | i32.shr_s 2423 | i32.add 2424 | i32.const 255 2425 | i32.and 2426 | i32.const 1 2427 | i32.shl 2428 | i32.load16_u offset=544 2429 | local.set $8 2430 | local.get $5 2431 | local.get $1 2432 | i32.const 13 2433 | i32.shr_u 2434 | i32.const 1 2435 | i32.and 2436 | local.get $0 2437 | i32.const 27 2438 | i32.shr_u 2439 | i32.const 2 2440 | i32.and 2441 | local.get $4 2442 | i32.const 4 2443 | i32.shr_u 2444 | i32.const 4 2445 | i32.and 2446 | local.get $0 2447 | i32.const 2 2448 | i32.shl 2449 | i32.const 16 2450 | i32.and 2451 | local.get $4 2452 | i32.const 9 2453 | i32.shr_u 2454 | i32.const 8 2455 | i32.and 2456 | i32.or 2457 | i32.or 2458 | i32.or 2459 | i32.or 2460 | i32.const 27 2461 | i32.shl 2462 | i32.const 27 2463 | i32.shr_s 2464 | i32.add 2465 | i32.const 255 2466 | i32.and 2467 | i32.const 1 2468 | i32.shl 2469 | i32.load16_u offset=544 2470 | local.set $5 2471 | br $break|20 2472 | end 2473 | local.get $1 2474 | i32.const 5 2475 | i32.shr_u 2476 | i32.const 255 2477 | i32.and 2478 | local.tee $7 2479 | i32.const 1 2480 | i32.shl 2481 | i32.load16_u offset=544 2482 | local.set $12 2483 | local.get $1 2484 | i32.const 15 2485 | i32.shr_u 2486 | i32.const 255 2487 | i32.and 2488 | local.tee $8 2489 | i32.const 1 2490 | i32.shl 2491 | i32.load16_u offset=544 2492 | local.set $16 2493 | local.get $6 2494 | i64.const 25 2495 | i64.shr_u 2496 | i64.const 255 2497 | i64.and 2498 | i32.wrap_i64 2499 | local.tee $5 2500 | i32.const 1 2501 | i32.shl 2502 | i32.load16_u offset=544 2503 | local.set $11 2504 | local.get $7 2505 | local.get $0 2506 | i32.const 3 2507 | i32.shr_u 2508 | i32.const 27 2509 | i32.shl 2510 | i32.const 27 2511 | i32.shr_s 2512 | i32.add 2513 | i32.const 255 2514 | i32.and 2515 | i32.const 1 2516 | i32.shl 2517 | i32.load16_u offset=544 2518 | local.set $15 2519 | local.get $8 2520 | local.get $0 2521 | i32.const 13 2522 | i32.shr_u 2523 | i32.const 27 2524 | i32.shl 2525 | i32.const 27 2526 | i32.shr_s 2527 | i32.add 2528 | i32.const 255 2529 | i32.and 2530 | i32.const 1 2531 | i32.shl 2532 | i32.load16_u offset=544 2533 | local.set $14 2534 | local.get $5 2535 | local.get $0 2536 | i32.const 23 2537 | i32.shr_u 2538 | i32.const 26 2539 | i32.shl 2540 | i32.const 26 2541 | i32.shr_s 2542 | i32.add 2543 | i32.const 255 2544 | i32.and 2545 | i32.const 1 2546 | i32.shl 2547 | i32.load16_u offset=544 2548 | local.set $10 2549 | local.get $7 2550 | local.get $4 2551 | i32.const 1 2552 | i32.shr_u 2553 | i32.const 27 2554 | i32.shl 2555 | i32.const 27 2556 | i32.shr_s 2557 | i32.add 2558 | i32.const 255 2559 | i32.and 2560 | i32.const 1 2561 | i32.shl 2562 | i32.load16_u offset=544 2563 | local.set $13 2564 | local.get $8 2565 | local.get $1 2566 | i32.const 20 2567 | i32.shr_u 2568 | i32.const 16 2569 | i32.and 2570 | local.get $0 2571 | i32.const 9 2572 | i32.shr_u 2573 | i32.const 15 2574 | i32.and 2575 | i32.or 2576 | i32.const 27 2577 | i32.shl 2578 | i32.const 27 2579 | i32.shr_s 2580 | i32.add 2581 | i32.const 255 2582 | i32.and 2583 | i32.const 1 2584 | i32.shl 2585 | i32.load16_u offset=544 2586 | local.set $9 2587 | local.get $5 2588 | local.get $4 2589 | i32.const 3 2590 | i32.shl 2591 | i32.const 8 2592 | i32.and 2593 | local.get $1 2594 | i32.const 18 2595 | i32.shr_u 2596 | i32.const 32 2597 | i32.and 2598 | local.get $1 2599 | i32.const 10 2600 | i32.shr_u 2601 | i32.const 16 2602 | i32.and 2603 | i32.or 2604 | i32.or 2605 | local.get $0 2606 | i32.const 29 2607 | i32.shr_u 2608 | i32.or 2609 | i32.const 26 2610 | i32.shl 2611 | i32.const 26 2612 | i32.shr_s 2613 | i32.add 2614 | i32.const 255 2615 | i32.and 2616 | i32.const 1 2617 | i32.shl 2618 | i32.load16_u offset=544 2619 | local.set $17 2620 | local.get $7 2621 | local.get $4 2622 | i32.const 7 2623 | i32.shr_u 2624 | i32.const 27 2625 | i32.shl 2626 | i32.const 27 2627 | i32.shr_s 2628 | i32.add 2629 | i32.const 255 2630 | i32.and 2631 | i32.const 1 2632 | i32.shl 2633 | i32.load16_u offset=544 2634 | local.set $7 2635 | local.get $8 2636 | local.get $0 2637 | i32.const 4 2638 | i32.shr_u 2639 | i32.const 16 2640 | i32.and 2641 | local.get $0 2642 | i32.const 19 2643 | i32.shr_u 2644 | i32.const 15 2645 | i32.and 2646 | i32.or 2647 | i32.const 27 2648 | i32.shl 2649 | i32.const 27 2650 | i32.shr_s 2651 | i32.add 2652 | i32.const 255 2653 | i32.and 2654 | i32.const 1 2655 | i32.shl 2656 | i32.load16_u offset=544 2657 | local.set $8 2658 | local.get $5 2659 | local.get $0 2660 | i32.const 18 2661 | i32.shr_u 2662 | i32.const 1 2663 | i32.and 2664 | local.get $1 2665 | i32.const 12 2666 | i32.shr_u 2667 | i32.const 2 2668 | i32.and 2669 | local.get $4 2670 | i32.const 4 2671 | i32.shr_u 2672 | i32.const 4 2673 | i32.and 2674 | local.get $4 2675 | i32.const 9 2676 | i32.shr_u 2677 | i32.const 8 2678 | i32.and 2679 | local.get $0 2680 | i32.const 4 2681 | i32.shl 2682 | i32.const 32 2683 | i32.and 2684 | local.get $0 2685 | i32.const 2 2686 | i32.shl 2687 | i32.const 16 2688 | i32.and 2689 | i32.or 2690 | i32.or 2691 | i32.or 2692 | i32.or 2693 | i32.or 2694 | i32.const 26 2695 | i32.shl 2696 | i32.const 26 2697 | i32.shr_s 2698 | i32.add 2699 | i32.const 255 2700 | i32.and 2701 | i32.const 1 2702 | i32.shl 2703 | i32.load16_u offset=544 2704 | local.set $5 2705 | br $break|20 2706 | end 2707 | local.get $1 2708 | i32.const 5 2709 | i32.shr_u 2710 | i32.const 63 2711 | i32.and 2712 | i32.const 1 2713 | i32.shl 2714 | i32.load16_u offset=160 2715 | local.set $12 2716 | local.get $1 2717 | i32.const 15 2718 | i32.shr_u 2719 | i32.const 63 2720 | i32.and 2721 | i32.const 1 2722 | i32.shl 2723 | i32.load16_u offset=160 2724 | local.set $16 2725 | local.get $1 2726 | i32.const 25 2727 | i32.shr_u 2728 | i32.const 63 2729 | i32.and 2730 | i32.const 1 2731 | i32.shl 2732 | i32.load16_u offset=160 2733 | local.set $11 2734 | local.get $0 2735 | i32.const 3 2736 | i32.shr_u 2737 | i32.const 63 2738 | i32.and 2739 | i32.const 1 2740 | i32.shl 2741 | i32.load16_u offset=160 2742 | local.set $15 2743 | local.get $0 2744 | i32.const 13 2745 | i32.shr_u 2746 | i32.const 63 2747 | i32.and 2748 | i32.const 1 2749 | i32.shl 2750 | i32.load16_u offset=160 2751 | local.set $14 2752 | local.get $0 2753 | i32.const 23 2754 | i32.shr_u 2755 | i32.const 63 2756 | i32.and 2757 | i32.const 1 2758 | i32.shl 2759 | i32.load16_u offset=160 2760 | local.set $10 2761 | local.get $4 2762 | i32.const 1 2763 | i32.shr_u 2764 | i32.const 63 2765 | i32.and 2766 | i32.const 1 2767 | i32.shl 2768 | i32.load16_u offset=160 2769 | local.set $13 2770 | local.get $0 2771 | i32.const 9 2772 | i32.shr_u 2773 | i32.const 15 2774 | i32.and 2775 | local.get $1 2776 | i32.const 16 2777 | i32.shr_u 2778 | i32.const 32 2779 | i32.and 2780 | local.get $1 2781 | i32.const 20 2782 | i32.shr_u 2783 | i32.const 16 2784 | i32.and 2785 | i32.or 2786 | i32.or 2787 | i32.const 1 2788 | i32.shl 2789 | i32.load16_u offset=160 2790 | local.set $9 2791 | local.get $4 2792 | i32.const 3 2793 | i32.shl 2794 | i32.const 8 2795 | i32.and 2796 | local.get $1 2797 | i32.const 17 2798 | i32.shr_u 2799 | i32.const 32 2800 | i32.and 2801 | local.get $1 2802 | i32.const 10 2803 | i32.shr_u 2804 | i32.const 16 2805 | i32.and 2806 | i32.or 2807 | i32.or 2808 | local.get $0 2809 | i32.const 29 2810 | i32.shr_u 2811 | i32.or 2812 | i32.const 1 2813 | i32.shl 2814 | i32.load16_u offset=160 2815 | local.set $17 2816 | local.get $4 2817 | i32.const 7 2818 | i32.shr_u 2819 | i32.const 63 2820 | i32.and 2821 | i32.const 1 2822 | i32.shl 2823 | i32.load16_u offset=160 2824 | local.set $7 2825 | local.get $0 2826 | i32.const 19 2827 | i32.shr_u 2828 | i32.const 15 2829 | i32.and 2830 | local.get $1 2831 | i32.const 26 2832 | i32.shr_u 2833 | i32.const 32 2834 | i32.and 2835 | local.get $1 2836 | i32.const 7 2837 | i32.shr_u 2838 | i32.const 16 2839 | i32.and 2840 | i32.or 2841 | i32.or 2842 | i32.const 1 2843 | i32.shl 2844 | i32.load16_u offset=160 2845 | local.set $8 2846 | local.get $1 2847 | i32.const 12 2848 | i32.shr_u 2849 | i32.const 3 2850 | i32.and 2851 | local.get $1 2852 | i32.const 21 2853 | i32.shr_u 2854 | i32.const 4 2855 | i32.and 2856 | local.get $0 2857 | i32.const 3 2858 | i32.shl 2859 | i32.const 8 2860 | i32.and 2861 | local.get $0 2862 | i32.const 4 2863 | i32.shl 2864 | i32.const 32 2865 | i32.and 2866 | local.get $0 2867 | i32.const 2 2868 | i32.shl 2869 | i32.const 16 2870 | i32.and 2871 | i32.or 2872 | i32.or 2873 | i32.or 2874 | i32.or 2875 | i32.const 1 2876 | i32.shl 2877 | i32.load16_u offset=160 2878 | local.set $5 2879 | end 2880 | local.get $18 2881 | i64.const 18 2882 | i64.shr_u 2883 | i64.const 3 2884 | i64.and 2885 | i64.const -1 2886 | block $assembly/decoder/getAnchor|inlined.0 (result i32) 2887 | i32.const 15 2888 | local.get $18 2889 | i64.const 13 2890 | i64.shr_u 2891 | i32.wrap_i64 2892 | i32.const 31 2893 | i32.and 2894 | local.tee $1 2895 | i32.const 16 2896 | i32.lt_u 2897 | br_if $assembly/decoder/getAnchor|inlined.0 2898 | drop 2899 | i64.const 2488276740032571439 2900 | local.get $1 2901 | i32.const 15 2902 | i32.and 2903 | i32.const 2 2904 | i32.shl 2905 | i64.extend_i32_u 2906 | i64.shr_s 2907 | i32.wrap_i64 2908 | i32.const 15 2909 | i32.and 2910 | end 2911 | i32.const 3 2912 | i32.mul 2913 | local.tee $0 2914 | i32.const 3 2915 | i32.add 2916 | i64.extend_i32_u 2917 | i64.shl 2918 | local.get $18 2919 | i64.const 16 2920 | i64.shr_u 2921 | i64.and 2922 | i64.const -1 2923 | i64.const 65 2924 | local.get $0 2925 | i64.extend_i32_u 2926 | i64.sub 2927 | i64.shr_u 2928 | i64.const 3 2929 | i64.shl 2930 | local.get $18 2931 | i64.const 17 2932 | i64.shr_u 2933 | i64.and 2934 | i64.or 2935 | i64.or 2936 | local.set $6 2937 | local.get $12 2938 | i32.const 6 2939 | i32.shl 2940 | i32.const 32 2941 | i32.add 2942 | local.set $19 2943 | local.get $16 2944 | i32.const 6 2945 | i32.shl 2946 | i32.const 32 2947 | i32.add 2948 | local.set $20 2949 | local.get $11 2950 | i32.const 6 2951 | i32.shl 2952 | i32.const 32 2953 | i32.add 2954 | local.set $21 2955 | local.get $13 2956 | i32.const 6 2957 | i32.shl 2958 | i32.const 32 2959 | i32.add 2960 | local.set $22 2961 | local.get $9 2962 | i32.const 6 2963 | i32.shl 2964 | i32.const 32 2965 | i32.add 2966 | local.set $23 2967 | local.get $17 2968 | i32.const 6 2969 | i32.shl 2970 | i32.const 32 2971 | i32.add 2972 | local.set $24 2973 | local.get $15 2974 | local.get $12 2975 | i32.sub 2976 | local.set $15 2977 | local.get $14 2978 | local.get $16 2979 | i32.sub 2980 | local.set $14 2981 | local.get $10 2982 | local.get $11 2983 | i32.sub 2984 | local.set $10 2985 | local.get $7 2986 | local.get $13 2987 | i32.sub 2988 | local.set $13 2989 | local.get $8 2990 | local.get $9 2991 | i32.sub 2992 | local.set $12 2993 | local.get $5 2994 | local.get $17 2995 | i32.sub 2996 | local.set $16 2997 | local.get $1 2998 | i32.const 1 2999 | i32.shl 3000 | i32.load16_u offset=32 3001 | local.set $1 3002 | loop $for-loop|141 3003 | local.get $25 3004 | i32.const 4 3005 | i32.lt_s 3006 | if 3007 | local.get $6 3008 | i32.wrap_i64 3009 | i32.const 7 3010 | i32.and 3011 | i32.load8_u offset=16 3012 | local.set $4 3013 | local.get $3 3014 | local.get $1 3015 | i32.const 1 3016 | i32.and 3017 | if (result i32) 3018 | local.get $22 3019 | local.get $4 3020 | local.get $13 3021 | i32.mul 3022 | i32.add 3023 | i32.const 6 3024 | i32.shr_u 3025 | local.set $0 3026 | local.get $23 3027 | local.get $4 3028 | local.get $12 3029 | i32.mul 3030 | i32.add 3031 | i32.const 6 3032 | i32.shr_u 3033 | local.set $9 3034 | local.get $24 3035 | local.get $4 3036 | local.get $16 3037 | i32.mul 3038 | i32.add 3039 | i32.const 6 3040 | i32.shr_u 3041 | else 3042 | local.get $19 3043 | local.get $4 3044 | local.get $15 3045 | i32.mul 3046 | i32.add 3047 | i32.const 6 3048 | i32.shr_u 3049 | local.set $0 3050 | local.get $20 3051 | local.get $4 3052 | local.get $14 3053 | i32.mul 3054 | i32.add 3055 | i32.const 6 3056 | i32.shr_u 3057 | local.set $9 3058 | local.get $21 3059 | local.get $4 3060 | local.get $10 3061 | i32.mul 3062 | i32.add 3063 | i32.const 6 3064 | i32.shr_u 3065 | end 3066 | i32.const 63488 3067 | i32.mul 3068 | i32.const -4194304 3069 | i32.and 3070 | local.get $9 3071 | i32.const 62 3072 | i32.mul 3073 | i32.const 4192256 3074 | i32.and 3075 | i32.or 3076 | local.get $0 3077 | i32.const 31 3078 | i32.mul 3079 | i32.const 10 3080 | i32.shr_u 3081 | i32.or 3082 | i32.store 3083 | local.get $6 3084 | i64.const 3 3085 | i64.shr_u 3086 | local.tee $6 3087 | i32.wrap_i64 3088 | i32.const 7 3089 | i32.and 3090 | i32.load8_u offset=16 3091 | local.set $0 3092 | local.get $3 3093 | local.get $1 3094 | i32.const 1 3095 | i32.shr_u 3096 | local.tee $4 3097 | i32.const 1 3098 | i32.and 3099 | if (result i32) 3100 | local.get $22 3101 | local.get $0 3102 | local.get $13 3103 | i32.mul 3104 | i32.add 3105 | i32.const 6 3106 | i32.shr_u 3107 | local.set $11 3108 | local.get $23 3109 | local.get $0 3110 | local.get $12 3111 | i32.mul 3112 | i32.add 3113 | i32.const 6 3114 | i32.shr_u 3115 | local.set $9 3116 | local.get $24 3117 | local.get $0 3118 | local.get $16 3119 | i32.mul 3120 | i32.add 3121 | i32.const 6 3122 | i32.shr_u 3123 | else 3124 | local.get $19 3125 | local.get $0 3126 | local.get $15 3127 | i32.mul 3128 | i32.add 3129 | i32.const 6 3130 | i32.shr_u 3131 | local.set $11 3132 | local.get $20 3133 | local.get $0 3134 | local.get $14 3135 | i32.mul 3136 | i32.add 3137 | i32.const 6 3138 | i32.shr_u 3139 | local.set $9 3140 | local.get $21 3141 | local.get $0 3142 | local.get $10 3143 | i32.mul 3144 | i32.add 3145 | i32.const 6 3146 | i32.shr_u 3147 | end 3148 | i32.const 63488 3149 | i32.mul 3150 | i32.const -4194304 3151 | i32.and 3152 | local.get $9 3153 | i32.const 62 3154 | i32.mul 3155 | i32.const 4192256 3156 | i32.and 3157 | i32.or 3158 | local.get $11 3159 | i32.const 31 3160 | i32.mul 3161 | i32.const 10 3162 | i32.shr_u 3163 | i32.or 3164 | i32.store offset=4 3165 | local.get $6 3166 | i64.const 3 3167 | i64.shr_u 3168 | local.tee $6 3169 | i32.wrap_i64 3170 | i32.const 7 3171 | i32.and 3172 | i32.load8_u offset=16 3173 | local.set $1 3174 | local.get $3 3175 | local.get $4 3176 | i32.const 1 3177 | i32.shr_u 3178 | local.tee $4 3179 | i32.const 1 3180 | i32.and 3181 | if (result i32) 3182 | local.get $22 3183 | local.get $1 3184 | local.get $13 3185 | i32.mul 3186 | i32.add 3187 | i32.const 6 3188 | i32.shr_u 3189 | local.set $0 3190 | local.get $23 3191 | local.get $1 3192 | local.get $12 3193 | i32.mul 3194 | i32.add 3195 | i32.const 6 3196 | i32.shr_u 3197 | local.set $9 3198 | local.get $24 3199 | local.get $1 3200 | local.get $16 3201 | i32.mul 3202 | i32.add 3203 | i32.const 6 3204 | i32.shr_u 3205 | else 3206 | local.get $19 3207 | local.get $1 3208 | local.get $15 3209 | i32.mul 3210 | i32.add 3211 | i32.const 6 3212 | i32.shr_u 3213 | local.set $0 3214 | local.get $20 3215 | local.get $1 3216 | local.get $14 3217 | i32.mul 3218 | i32.add 3219 | i32.const 6 3220 | i32.shr_u 3221 | local.set $9 3222 | local.get $21 3223 | local.get $1 3224 | local.get $10 3225 | i32.mul 3226 | i32.add 3227 | i32.const 6 3228 | i32.shr_u 3229 | end 3230 | i32.const 63488 3231 | i32.mul 3232 | i32.const -4194304 3233 | i32.and 3234 | local.get $9 3235 | i32.const 62 3236 | i32.mul 3237 | i32.const 4192256 3238 | i32.and 3239 | i32.or 3240 | local.get $0 3241 | i32.const 31 3242 | i32.mul 3243 | i32.const 10 3244 | i32.shr_u 3245 | i32.or 3246 | i32.store offset=8 3247 | local.get $6 3248 | i64.const 3 3249 | i64.shr_u 3250 | local.tee $6 3251 | i32.wrap_i64 3252 | i32.const 7 3253 | i32.and 3254 | i32.load8_u offset=16 3255 | local.set $0 3256 | local.get $3 3257 | local.get $4 3258 | i32.const 1 3259 | i32.shr_u 3260 | local.tee $1 3261 | i32.const 1 3262 | i32.and 3263 | if (result i32) 3264 | local.get $22 3265 | local.get $0 3266 | local.get $13 3267 | i32.mul 3268 | i32.add 3269 | i32.const 6 3270 | i32.shr_u 3271 | local.set $11 3272 | local.get $23 3273 | local.get $0 3274 | local.get $12 3275 | i32.mul 3276 | i32.add 3277 | i32.const 6 3278 | i32.shr_u 3279 | local.set $9 3280 | local.get $24 3281 | local.get $0 3282 | local.get $16 3283 | i32.mul 3284 | i32.add 3285 | i32.const 6 3286 | i32.shr_u 3287 | else 3288 | local.get $19 3289 | local.get $0 3290 | local.get $15 3291 | i32.mul 3292 | i32.add 3293 | i32.const 6 3294 | i32.shr_u 3295 | local.set $11 3296 | local.get $20 3297 | local.get $0 3298 | local.get $14 3299 | i32.mul 3300 | i32.add 3301 | i32.const 6 3302 | i32.shr_u 3303 | local.set $9 3304 | local.get $21 3305 | local.get $0 3306 | local.get $10 3307 | i32.mul 3308 | i32.add 3309 | i32.const 6 3310 | i32.shr_u 3311 | end 3312 | i32.const 63488 3313 | i32.mul 3314 | i32.const -4194304 3315 | i32.and 3316 | local.get $9 3317 | i32.const 62 3318 | i32.mul 3319 | i32.const 4192256 3320 | i32.and 3321 | i32.or 3322 | local.get $11 3323 | i32.const 31 3324 | i32.mul 3325 | i32.const 10 3326 | i32.shr_u 3327 | i32.or 3328 | i32.store offset=12 3329 | local.get $6 3330 | i64.const 3 3331 | i64.shr_u 3332 | local.set $6 3333 | local.get $1 3334 | i32.const 1 3335 | i32.shr_u 3336 | local.set $1 3337 | local.get $2 3338 | local.get $3 3339 | i32.add 3340 | local.set $3 3341 | local.get $25 3342 | i32.const 1 3343 | i32.add 3344 | local.set $25 3345 | br $for-loop|141 3346 | end 3347 | end 3348 | end 3349 | ) 3350 | (func $assembly/decoder/decode (param $0 i32) (param $1 i32) (result i32) 3351 | (local $2 i32) 3352 | (local $3 i32) 3353 | (local $4 i32) 3354 | (local $5 i32) 3355 | (local $6 i32) 3356 | (local $7 i32) 3357 | (local $8 i32) 3358 | (local $9 i32) 3359 | (local $10 i32) 3360 | (local $11 i32) 3361 | local.get $0 3362 | local.get $1 3363 | i32.or 3364 | i32.const 0 3365 | i32.lt_s 3366 | if 3367 | i32.const 1 3368 | return 3369 | end 3370 | local.get $1 3371 | i32.const 3 3372 | i32.add 3373 | i32.const 2 3374 | i32.shr_s 3375 | local.tee $10 3376 | local.get $0 3377 | i32.const 3 3378 | i32.add 3379 | i32.const 2 3380 | i32.shr_s 3381 | local.tee $6 3382 | i32.mul 3383 | i32.const 4 3384 | i32.shl 3385 | local.tee $9 3386 | local.get $0 3387 | local.get $10 3388 | i32.const 2 3389 | i32.shl 3390 | i32.mul 3391 | i32.const 2 3392 | i32.shl 3393 | i32.add 3394 | memory.size 3395 | i32.const 1 3396 | i32.sub 3397 | i32.const 16 3398 | i32.shl 3399 | i32.gt_s 3400 | if 3401 | i32.const 1 3402 | return 3403 | end 3404 | global.get $assembly/decoder/firstRun 3405 | if 3406 | i32.const 0 3407 | i64.const 2169069333509637120 3408 | i64.store 3409 | i32.const 8 3410 | i64.const 4628635210004244002 3411 | i64.store 3412 | i32.const 16 3413 | i64.const 4627217879049308416 3414 | i64.store 3415 | i32.const 32 3416 | i64.const -1384594177156133684 3417 | i64.store 3418 | i32.const 40 3419 | i64.const -1404842944515749760 3420 | i64.store 3421 | i32.const 48 3422 | i64.const -1729102426907293696 3423 | i64.store 3424 | i32.const 56 3425 | i64.const -1152640094071357464 3426 | i64.store 3427 | i32.const 64 3428 | i64.const 634568842329126672 3429 | i64.store 3430 | i32.const 72 3431 | i64.const -8300643185197055860 3432 | i64.store 3433 | i32.const 80 3434 | i64.const 3921621964628691084 3435 | i64.store 3436 | i32.const 88 3437 | i64.const 4151317811495442408 3438 | i64.store 3439 | i32.const 96 3440 | i64.const 4042024681196232704 3441 | i64.store 3442 | i32.const 104 3443 | i64.const 4331385372548539396 3444 | i64.store 3445 | i32.const 112 3446 | i64.const 4186705026872386050 3447 | i64.store 3448 | i32.const 120 3449 | i64.const 4476065718224692742 3450 | i64.store 3451 | i32.const 128 3452 | i64.const 4114364854034309377 3453 | i64.store 3454 | i32.const 136 3455 | i64.const 4403725545386616069 3456 | i64.store 3457 | i32.const 144 3458 | i64.const 4259045199710462723 3459 | i64.store 3460 | i32.const 152 3461 | i64.const 4548405891062769415 3462 | i64.store 3463 | i32.const 6 3464 | local.set $2 3465 | i32.const 160 3466 | local.set $3 3467 | loop $for-loop|0 3468 | local.get $2 3469 | i32.const 13 3470 | i32.lt_u 3471 | if 3472 | i32.const 1 3473 | i32.const 15 3474 | local.get $2 3475 | i32.sub 3476 | i32.shl 3477 | local.tee $7 3478 | i32.const 1 3479 | local.get $2 3480 | i32.shl 3481 | local.tee $4 3482 | i32.const 1 3483 | i32.sub 3484 | i32.const 16 3485 | local.get $2 3486 | i32.sub 3487 | i32.shl 3488 | i32.or 3489 | local.set $5 3490 | i32.const 0 3491 | local.set $1 3492 | loop $for-loop|1 3493 | local.get $1 3494 | local.get $4 3495 | i32.lt_u 3496 | if 3497 | local.get $3 3498 | local.get $1 3499 | i32.const 1 3500 | i32.shl 3501 | i32.add 3502 | i32.const 65535 3503 | local.get $1 3504 | i32.const 16 3505 | local.get $2 3506 | i32.sub 3507 | i32.shl 3508 | local.tee $8 3509 | local.get $7 3510 | i32.const 0 3511 | local.get $8 3512 | select 3513 | i32.or 3514 | local.tee $8 3515 | local.get $5 3516 | local.get $8 3517 | i32.eq 3518 | select 3519 | i32.store16 3520 | local.get $1 3521 | i32.const 1 3522 | i32.add 3523 | local.set $1 3524 | br $for-loop|1 3525 | end 3526 | end 3527 | local.get $3 3528 | local.get $4 3529 | i32.const 1 3530 | i32.shl 3531 | i32.add 3532 | local.set $3 3533 | local.get $2 3534 | i32.const 1 3535 | i32.add 3536 | local.set $2 3537 | br $for-loop|0 3538 | end 3539 | end 3540 | i32.const 0 3541 | global.set $assembly/decoder/firstRun 3542 | end 3543 | local.get $0 3544 | i32.const 2 3545 | i32.shr_s 3546 | local.set $5 3547 | local.get $0 3548 | i32.const 3 3549 | i32.and 3550 | i32.const 2 3551 | i32.shl 3552 | local.tee $7 3553 | local.get $0 3554 | i32.const 2 3555 | i32.shl 3556 | local.tee $4 3557 | i32.const 3 3558 | i32.mul 3559 | i32.add 3560 | local.set $8 3561 | i32.const 16 3562 | i32.const 0 3563 | local.get $7 3564 | select 3565 | local.set $11 3566 | i32.const 65536 3567 | local.set $2 3568 | local.get $9 3569 | i32.const 65536 3570 | i32.add 3571 | local.set $1 3572 | i32.const 0 3573 | local.set $0 3574 | loop $for-loop|2 3575 | local.get $0 3576 | local.get $10 3577 | i32.lt_s 3578 | if 3579 | i32.const 0 3580 | local.set $3 3581 | loop $for-loop|3 3582 | local.get $3 3583 | local.get $5 3584 | i32.lt_s 3585 | if 3586 | local.get $2 3587 | local.get $1 3588 | local.get $4 3589 | call $assembly/decoder/decodeBlock 3590 | local.get $2 3591 | i32.const 16 3592 | i32.add 3593 | local.set $2 3594 | local.get $1 3595 | i32.const 16 3596 | i32.add 3597 | local.set $1 3598 | local.get $3 3599 | i32.const 1 3600 | i32.add 3601 | local.set $3 3602 | br $for-loop|3 3603 | end 3604 | end 3605 | local.get $2 3606 | local.get $11 3607 | i32.add 3608 | local.set $2 3609 | local.get $1 3610 | local.get $8 3611 | i32.add 3612 | local.set $1 3613 | local.get $0 3614 | i32.const 1 3615 | i32.add 3616 | local.set $0 3617 | br $for-loop|2 3618 | end 3619 | end 3620 | local.get $7 3621 | if 3622 | local.get $5 3623 | i32.const 4 3624 | i32.shl 3625 | local.tee $0 3626 | i32.const 65536 3627 | i32.add 3628 | local.set $2 3629 | local.get $0 3630 | local.get $9 3631 | i32.const 65536 3632 | i32.add 3633 | i32.add 3634 | local.set $1 3635 | local.get $6 3636 | i32.const 4 3637 | i32.shl 3638 | local.set $9 3639 | local.get $4 3640 | i32.const 2 3641 | i32.shl 3642 | local.set $5 3643 | i32.const 0 3644 | local.set $3 3645 | loop $for-loop|4 3646 | local.get $3 3647 | local.get $10 3648 | i32.lt_s 3649 | if 3650 | local.get $2 3651 | i32.const 32768 3652 | i32.const 16 3653 | call $assembly/decoder/decodeBlock 3654 | i32.const 0 3655 | local.set $0 3656 | loop $for-loop|5 3657 | local.get $0 3658 | local.get $7 3659 | i32.lt_s 3660 | if 3661 | local.get $0 3662 | local.get $1 3663 | i32.add 3664 | local.get $0 3665 | i32.load offset=32768 3666 | i32.store 3667 | local.get $0 3668 | local.get $1 3669 | local.get $4 3670 | i32.add 3671 | local.tee $6 3672 | i32.add 3673 | local.get $0 3674 | i32.load offset=32784 3675 | i32.store 3676 | local.get $0 3677 | local.get $4 3678 | local.get $6 3679 | i32.add 3680 | local.tee $6 3681 | i32.add 3682 | local.get $0 3683 | i32.load offset=32800 3684 | i32.store 3685 | local.get $0 3686 | local.get $4 3687 | local.get $6 3688 | i32.add 3689 | i32.add 3690 | local.get $0 3691 | i32.load offset=32816 3692 | i32.store 3693 | local.get $0 3694 | i32.const 4 3695 | i32.add 3696 | local.set $0 3697 | br $for-loop|5 3698 | end 3699 | end 3700 | local.get $2 3701 | local.get $9 3702 | i32.add 3703 | local.set $2 3704 | local.get $1 3705 | local.get $5 3706 | i32.add 3707 | local.set $1 3708 | local.get $3 3709 | i32.const 1 3710 | i32.add 3711 | local.set $3 3712 | br $for-loop|4 3713 | end 3714 | end 3715 | end 3716 | i32.const 0 3717 | ) 3718 | ) 3719 | -------------------------------------------------------------------------------- /build/bc6hu-rgb32f.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/bc6hu-rgb32f.wasm -------------------------------------------------------------------------------- /build/bc6hu-rgb9e5.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/bc6hu-rgb9e5.wasm -------------------------------------------------------------------------------- /build/bc6hu-rgba16f.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/bc6hu-rgba16f.wasm -------------------------------------------------------------------------------- /build/generator.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/BC6H-Decoder-WASM/322615ff672508d08f4781588fad6938062df2e7/build/generator.wasm -------------------------------------------------------------------------------- /build/generator.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_i32 (func (param i32) (result i32))) 3 | (type $i32_i64_=>_none (func (param i32 i64))) 4 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 5 | (type $i64_i64_=>_i64 (func (param i64 i64) (result i64))) 6 | (import "env" "memory" (memory $0 1)) 7 | (data (i32.const 63488) "\00\00\00\00\00\00\00\00y\8950\c8p\d8z\f2\12k`\90\e1\b0\f5\8b\9b^PX\91h\8f\8f\b6A\98s\e58\c0\f6?t\a8\bb\95\e0\ba}\a4*\f8\e3\04\885\04-\1f\c8+tPOu\fe\14h\b4\ec(\ab\0cw!X|\9c\f0\d1\87\ec\7f\08$\0d\98^\feeJ8\ec}@$\faHU\f0\c7\t\10k\83\c1`\c0\0fy\c8\11\08Z>\90W\e8\a0\9eq\d3\0b\a0\9f\98x\e4\81o\be\88;\ff\08}\f8\e6\8b\b8\f3\8f\d0\07s}\d5\e8\ab\1e\b8\88\n\f4\e0\d8cn`\f2\0e\d9\ff\10H\1a0\bdwP\ca \80j\e8\c7\fc\cb\94p\d8\fb\80H\85B\a1@\10\8bX2\f4\91\aa\e0\8f\13 \d6\8d\18\9f\d0Gc\f8\ac\06\83\c1\80\1f\f2\90#\7f\n\f4\b0\d7\82HY{\'\ebx\fc\f6\18\16\02\ae\deH4\86\c0l\895\80\18l\17\a8\e3\f0\bc\b5(\a4gp\99\02\df|\11w\fe\11\fa{VI!\bf\8e\c9\80\f0\cd\17q\e7\1f\a1\0f\89D\"A/oyu\8di=\89\04\1b):\f4\e0\08\b9\cck\f1@\7f{V\e9\94\fa\99\cf\06\f2c\d9\\\8aA\b5w!hy\c3\129Q\0e\a8]I\0bb\e1+\853\03\19S\f3\89\a4\fc\ba6)\9b\83Q\de\f8\97)\e1\b0\f7\01\91\81\1e\1c\d1x\87\d9\eb\n\85B\81 \16\b1ds\0cw\b1\e8fi\1e\83\b0\c2\99L\01\19\87\fa9\f7\a9\84q\c1\fdq\a2\a9\f9\dc\e0\a9r\08+\9c\c9\14\90q\08\0c\06\83\01?\e4!Gu\8f\b61\f7\94\f9=\fe\14\e8a\af\05\91\b2\87\9d\ddQguI\c8\f6N\d6\f1\f8\ed1,\8f\c7\e3\c10\9d\e9V\04\\\bd\91h\0c\81\d9}\d5\88\a1\a0|Y\a3y\f8\97i\8b\08\t\ec\00q\a2YCx\d1\96\8b\ea\fc\t\1b\e9\b9\19\f2c\c99\d3\99aco-nz\bd\daz\df\16\a4[Ju\aa\a2\a5\9d?\05\1a-;\ca*\e4\b60*\e5K\12P\e0\9b/\e2\ce?B\1f\99\12\1a\d2\06O\9ae\12\89D\82^\de\f2\eak\00q\b2\96\ae*\90\1a\d3z\12\t6RtcZO\"\c1F\8a\0e\e8\c1\11r\99\d7\e2\81\91H$BQ\a7:\fb\95e;\8az\d3j\b4\ec\ec\0e\ba\b2\a3\b2\cegwP\ea\ea2\daA\1e\fee\da\"B\02;\eeB\d0\f2\86%r\a2\97\cb\e5\c2NU\aa\d8\1cP\bb\92\16\c4\c2We\d9\8e\a2\de\b4\1a-a\f4\91j\f5\c0Jb\18}\a4Z=\b0\92\18\93\e6\fa\ne!\fa\97\eao\cf:\adQ\"\ed\9b\bc\c4\9a2\c9Z\t\e25\f1\aa\fa\b9\82si\ae\af\fa\a2(\ea\fc\10\'\9a\cajX2\86\14\n\85\02A,b\c9m\83\b02\89\\\ba\b3\e6\18\eeb\d1\cd\d2<\9f\91\dbR\19\bd\nFm\f2\12k\ca$k%\14{\'[\02T\b3_\9f\e0y\0bZ\c5\db\d0\e6iL;\92\b5\03\aa\e2DS\f3\b9\c1S\e5\9b\cdf\c3q\b1\8b\9f\10V8\93) \e3\10i\df\0d\a3\e1P;j\18\0c\06\03~\c8C\8ea\8533\b6\b8\9b\f4\ea\1emc\ee)\f3{\93\97XS&Y+\01\97\baG\9b\0d-{N\ee3r\ab\c5]\a34e\a8,\fb\9d\cc\cb\bb\1c!\19\cbU\bc\13\c1\ec\9d\ac\e3\f1\dbcX\95\14\99\d39\ab\bb\"\1e\8f\c7\83a:\d3\adg\06\f2\b3\a9J\0b\d7c+\ed{\82>[\98\1a\a2\d8KJN\83\e2\919\86\1b\12\df\ebm\e8\b0\b3+\da\af3\17\99c\b8\8bE7K\f3\e0\ea\8d\bb\8dG\93\89kq\d3\eb\d5\d6\fb\06\12\f8\e6\db\1d\a6#|\16\d5\f9\136\d2s3o\\\cc#\fe\a2\abI\e4\c7\92s\a63\c3\c6\9dN\a7CnC\1b\bc\b5\c9K\ac)\93\ac\95\cc@~\9c\e1\e3t\efG\db \cc\b9r\1c`>R\15\fcq\02\c4\1a:\7f\n4Zv\94UC\f6?\04\92\06L/\c8maT\ca\97$\a0\b1\e4Td\02\e7\fc\da\c07_\c4\9d\7f\84>\b9\bej\f4U\0f\\D2%4\a4\0d\9e4\cbK\ac\01\94\c5\ee\ec\b1O\81\1e\\\ee\9a\bc\fe6\08+l&\ead\84\bd\93u<~{\0c\0b\c4\1a@\0c\b6\0b\d4q4\a6\f5$\12l\a4\e8M/\c0\14\da\1c|\92\c6\b4\9eD\82\8d\14\1d\bf=\abtJ\fd\ccg\bb\10\b4\bca\89\9c(\c2\99\81\8c\a9\f9DRI\02\df\dc\f1h,\dd0\8b\ea\ec9\18\f4\a7AX\e1L\a6\80\8cC8\d1\d4|n\f0T9\b3J\8a,6a<\b6\ca\c3\bf\1c\fe\11\e4\cc\ce\ee\a0\d4\d5e\b4\83\b7g\95\e4\1d\15l\f9<\fc\cb\b4E\84\04vEu\fe\84\8d\f4\dc\0c\b7\167\bd^m\bdo\ce\9f\02\8d\96\1de\15E\04\\\dd\ce\8c\0d\9a<\8di\ed\06\fc\d5\e08\a0v%-\88\85\afA)C\15\e5\f8]\d5\ca\b2\1dE\bdi5Z\b3;(uu\19\ed \c2\e8#\d5\ea\81\95\c4\bba\16\e5\"\f1M\be0\faH\b5z`%1Is}\85\b2\10\fdKM^bM\99d\ad\044\d7W}Q\14u~\bfL\t-\t\85\1d\f1\c6\c5<\1d\c1\f5\c5\8b6y\895e\92\b5\12O\f0\bc\05\ad\e2mh\c4k\e2U\f5s\05\e7\bd\e2\d7e=\03\dd\9d\b9\cf\c8\ad\16w\8d\d2\c0F\fd\9d\de\07U\a8K\dd\a3\cd\86\96=\'2T\96\fdN\e6\e5]C\87\9d]\d1~\9d\b9:\0e\a8m\19\0eE\c3\b1\95\f6=A\9f-L\c8\1c\c3\0d\89\ef\f56\cc1\dc\c5\a2\9b\a5y\b5\b8\e9\f5j\eb}\03>#\b7\a52z\15\8cG\aa\82\95\fa\n\cd\f6\da\e4%\d6\94I\d6J\a3m\10\e6\\9\0e0(\f6N\b6\04\a8f\bfQ\7f{\86\cc\d8\be\c5URdN\e7\ac\ee\8a,\dbQ~/\dc6\f0\a7@\0f.wM^\7f\de\c9:\1e\bf=\86\05\af\1a1\be \a5\fe\e1\d6\93\04\8e\e8\d5&\9b]\08Z\de\b0DN\14$\81o\eex4\96n \acp&S@\c6!Y%E\16\9b0\1e[\d2\be\1bF\c3\a1v\d4\ab7.v\0b\d1\ae\ae[\8b\9b^\af\b6\de7\"\02\aeng\c6\06M\a9\99\f0>?Wn\c2\d0\10\c5\0e\f7\'\b6\b8\d4=\da\c6\dcS\e6\f7\ad\b4\ef\f6\14#>\8d&/\b1\a6L\b2V\02_\a6\84\96\84\c2\8ex.u\8f6\1bZ\f6\9cW\fc\ba\06\d3*.\e6\dcg\e4V\8b\bbFi\a5\ee\d1fC\cb\9e\13\a1\c3\ce\aeh\bf\ce\\\d8J\fb\9e\a0\cf\16&S\d1\a5\ce\f8^~\a9*X\90\fe0.\a6\d3\d8;Y\c7\e3\b7\c7\b0\a1\b2l\f7+\c7\1f\ca*)2\a7sVwES\a0\07\97\bb&\af?W\8d\18_\90R\ffp.\04-oX\"\'\n\a5\9fs?\00\b3O\85\dc\16F\0f\c8\c3\97\ff\ad\c5M\afW[\ef\1b\d4Lx\9f\9f+7a_\d7&\cf\c7\ba_\ee&^\13\ff\0f\ca\87\94\"s\0c7$\be\d7\db[\fa9\07\ec\ce\0f\a1\d0agW\b4_g.\a9\e8Rg|/\bfTYT\e7O\d8H\cf\cd \dd\d2\7f\108\17\b7\abF\8c/H\a9\7f8\d2\cf\b9\1f\80\d9\a7B\d6\e2\a6\d7\ab\ad\f7\0d\afk\93\e7c\dd/w$\f0\cd\b7;LG\f8]y\f8\87\f3<\9f\82,\aa\f3\'l\a4\e7fU#\c6\17\a4\d4?\1c\de\b8\98G\fcEW\93\a71\adw45\8f\e9\a3\1c\b2\bf\1fA\df\a6\da\95\87\8f\d71\07\dcQ\0e\d9\df\8f\a0oS(\87\ec\efG\d0\b7)") 8 | (export "memory" (memory $0)) 9 | (export "generate" (func $assembly/generator/generate)) 10 | (export "generateAll" (func $assembly/generator/generateAll)) 11 | (export "generateAllSingleSubset" (func $assembly/generator/generateAllSingleSubset)) 12 | (export "generateAllDualSubset" (func $assembly/generator/generateAllDualSubset)) 13 | (func $assembly/generator/getActualMode (param $0 i32) (result i32) 14 | block $case18|0 15 | block $case17|0 16 | block $case16|0 17 | block $case15|0 18 | block $case14|0 19 | block $case13|0 20 | block $case12|0 21 | block $case11|0 22 | block $case10|0 23 | block $case9|0 24 | block $case8|0 25 | block $case7|0 26 | block $case6|0 27 | block $case5|0 28 | block $case4|0 29 | block $case3|0 30 | block $case2|0 31 | block $case1|0 32 | block $case0|0 33 | local.get $0 34 | br_table $case0|0 $case1|0 $case2|0 $case3|0 $case4|0 $case5|0 $case6|0 $case7|0 $case8|0 $case9|0 $case10|0 $case11|0 $case12|0 $case13|0 $case14|0 $case15|0 $case16|0 $case17|0 $case18|0 35 | end 36 | i32.const 0 37 | return 38 | end 39 | i32.const 1 40 | return 41 | end 42 | i32.const 2 43 | return 44 | end 45 | i32.const 6 46 | return 47 | end 48 | i32.const 10 49 | return 50 | end 51 | i32.const 14 52 | return 53 | end 54 | i32.const 18 55 | return 56 | end 57 | i32.const 22 58 | return 59 | end 60 | i32.const 26 61 | return 62 | end 63 | i32.const 30 64 | return 65 | end 66 | i32.const 3 67 | return 68 | end 69 | i32.const 7 70 | return 71 | end 72 | i32.const 11 73 | return 74 | end 75 | i32.const 15 76 | return 77 | end 78 | i32.const 19 79 | return 80 | end 81 | i32.const 23 82 | return 83 | end 84 | i32.const 27 85 | return 86 | end 87 | i32.const 31 88 | return 89 | end 90 | unreachable 91 | ) 92 | (func $assembly/generator/crc64 (param $0 i64) (param $1 i64) (result i64) 93 | local.get $0 94 | local.get $1 95 | i64.const 255 96 | i64.and 97 | i64.xor 98 | i64.const 255 99 | i64.and 100 | i32.wrap_i64 101 | i64.load offset=63488 102 | local.get $0 103 | i64.const 8 104 | i64.shr_u 105 | i64.xor 106 | local.tee $0 107 | local.get $1 108 | i64.const 8 109 | i64.shr_u 110 | i64.const 255 111 | i64.and 112 | i64.xor 113 | i64.const 255 114 | i64.and 115 | i32.wrap_i64 116 | i64.load offset=63488 117 | local.get $0 118 | i64.const 8 119 | i64.shr_u 120 | i64.xor 121 | local.tee $0 122 | local.get $1 123 | i64.const 16 124 | i64.shr_u 125 | i64.const 255 126 | i64.and 127 | i64.xor 128 | i64.const 255 129 | i64.and 130 | i32.wrap_i64 131 | i64.load offset=63488 132 | local.get $0 133 | i64.const 8 134 | i64.shr_u 135 | i64.xor 136 | local.tee $0 137 | local.get $1 138 | i64.const 24 139 | i64.shr_u 140 | i64.const 255 141 | i64.and 142 | i64.xor 143 | i64.const 255 144 | i64.and 145 | i32.wrap_i64 146 | i64.load offset=63488 147 | local.get $0 148 | i64.const 8 149 | i64.shr_u 150 | i64.xor 151 | local.tee $0 152 | local.get $1 153 | i64.const 32 154 | i64.shr_u 155 | i64.const 255 156 | i64.and 157 | i64.xor 158 | i64.const 255 159 | i64.and 160 | i32.wrap_i64 161 | i64.load offset=63488 162 | local.get $0 163 | i64.const 8 164 | i64.shr_u 165 | i64.xor 166 | local.tee $0 167 | local.get $1 168 | i64.const 40 169 | i64.shr_u 170 | i64.const 255 171 | i64.and 172 | i64.xor 173 | i64.const 255 174 | i64.and 175 | i32.wrap_i64 176 | i64.load offset=63488 177 | local.get $0 178 | i64.const 8 179 | i64.shr_u 180 | i64.xor 181 | local.tee $0 182 | local.get $1 183 | i64.const 48 184 | i64.shr_u 185 | i64.const 255 186 | i64.and 187 | i64.xor 188 | i64.const 255 189 | i64.and 190 | i32.wrap_i64 191 | i64.load offset=63488 192 | local.get $0 193 | i64.const 8 194 | i64.shr_u 195 | i64.xor 196 | local.tee $0 197 | local.get $1 198 | i64.const 58 199 | i64.shr_u 200 | i64.xor 201 | i64.const 255 202 | i64.and 203 | i32.wrap_i64 204 | i64.load offset=63488 205 | local.get $0 206 | i64.const 8 207 | i64.shr_u 208 | i64.xor 209 | ) 210 | (func $assembly/generator/writeBlock (param $0 i32) (param $1 i64) 211 | (local $2 i64) 212 | (local $3 i64) 213 | (local $4 i32) 214 | local.get $0 215 | i64.extend_i32_s 216 | i64.const 0 217 | local.get $1 218 | call $assembly/generator/crc64 219 | i64.const 2 220 | i64.const 5 221 | local.get $0 222 | i32.const 2 223 | i32.lt_s 224 | select 225 | i64.shl 226 | i64.or 227 | local.tee $3 228 | local.get $1 229 | call $assembly/generator/crc64 230 | local.set $2 231 | local.get $1 232 | i32.wrap_i64 233 | i32.const 4 234 | i32.shl 235 | i32.const 65536 236 | i32.add 237 | local.tee $4 238 | local.get $3 239 | i64.store 240 | local.get $4 241 | local.get $2 242 | i64.const -253953 243 | i64.and 244 | local.get $1 245 | i64.const 31 246 | i64.and 247 | i64.const 13 248 | i64.shl 249 | i64.or 250 | local.get $2 251 | local.get $0 252 | i32.const 3 253 | i32.and 254 | i32.const 3 255 | i32.ne 256 | select 257 | i64.store offset=8 258 | ) 259 | (func $assembly/generator/generate (param $0 i32) (param $1 i32) (result i32) 260 | (local $2 i32) 261 | i32.const 1 262 | local.get $1 263 | i32.const 0 264 | i32.lt_s 265 | i32.const 1 266 | local.get $0 267 | i32.const 0 268 | i32.lt_s 269 | local.get $0 270 | i32.const 17 271 | i32.gt_s 272 | select 273 | select 274 | if 275 | i32.const -1 276 | return 277 | end 278 | memory.size 279 | i32.const 1 280 | i32.sub 281 | i32.const 16 282 | i32.shl 283 | local.get $1 284 | i32.const 4 285 | i32.shl 286 | i32.lt_s 287 | if 288 | i32.const -1 289 | return 290 | end 291 | local.get $0 292 | call $assembly/generator/getActualMode 293 | local.set $0 294 | loop $for-loop|0 295 | local.get $1 296 | local.get $2 297 | i32.gt_s 298 | if 299 | local.get $0 300 | local.get $2 301 | i64.extend_i32_s 302 | call $assembly/generator/writeBlock 303 | local.get $2 304 | i32.const 1 305 | i32.add 306 | local.set $2 307 | br $for-loop|0 308 | end 309 | end 310 | local.get $0 311 | ) 312 | (func $assembly/generator/generateAll (param $0 i32) (result i32) 313 | (local $1 i32) 314 | local.get $0 315 | i32.const 0 316 | i32.lt_s 317 | if 318 | i32.const -1 319 | return 320 | end 321 | memory.size 322 | i32.const 1 323 | i32.sub 324 | i32.const 16 325 | i32.shl 326 | local.get $0 327 | i32.const 4 328 | i32.shl 329 | i32.lt_s 330 | if 331 | i32.const -1 332 | return 333 | end 334 | loop $for-loop|0 335 | local.get $0 336 | local.get $1 337 | i32.gt_s 338 | if 339 | local.get $1 340 | i32.const 3 341 | i32.mul 342 | local.get $1 343 | i32.const 14 344 | i32.div_s 345 | i32.add 346 | i32.const 1 347 | i32.add 348 | i32.const 14 349 | i32.rem_s 350 | call $assembly/generator/getActualMode 351 | local.get $1 352 | i64.extend_i32_s 353 | call $assembly/generator/writeBlock 354 | local.get $1 355 | i32.const 1 356 | i32.add 357 | local.set $1 358 | br $for-loop|0 359 | end 360 | end 361 | i32.const 0 362 | ) 363 | (func $assembly/generator/generateAllSingleSubset (param $0 i32) (result i32) 364 | (local $1 i64) 365 | (local $2 i64) 366 | memory.size 367 | i32.const 1 368 | i32.sub 369 | i32.const 16 370 | i32.shl 371 | local.get $0 372 | i32.const 4 373 | i32.shl 374 | i32.lt_u 375 | if 376 | i32.const -1 377 | return 378 | end 379 | local.get $0 380 | i64.extend_i32_u 381 | local.set $2 382 | loop $for-loop|0 383 | local.get $1 384 | local.get $2 385 | i64.lt_u 386 | if 387 | local.get $1 388 | i64.const 3 389 | i64.mul 390 | local.get $1 391 | i64.const 2 392 | i64.shr_u 393 | i64.add 394 | i64.const 1 395 | i64.add 396 | i32.wrap_i64 397 | i32.const 3 398 | i32.and 399 | i32.const 10 400 | i32.add 401 | call $assembly/generator/getActualMode 402 | local.get $1 403 | call $assembly/generator/writeBlock 404 | local.get $1 405 | i64.const 1 406 | i64.add 407 | local.set $1 408 | br $for-loop|0 409 | end 410 | end 411 | i32.const 0 412 | ) 413 | (func $assembly/generator/generateAllDualSubset (param $0 i32) (result i32) 414 | (local $1 i64) 415 | (local $2 i64) 416 | memory.size 417 | i32.const 1 418 | i32.sub 419 | i32.const 16 420 | i32.shl 421 | local.get $0 422 | i32.const 4 423 | i32.shl 424 | i32.lt_u 425 | if 426 | i32.const -1 427 | return 428 | end 429 | local.get $0 430 | i64.extend_i32_u 431 | local.set $2 432 | loop $for-loop|0 433 | local.get $1 434 | local.get $2 435 | i64.lt_u 436 | if 437 | local.get $1 438 | i64.const 3 439 | i64.mul 440 | local.get $1 441 | i64.const 10 442 | i64.div_u 443 | i64.add 444 | i64.const 1 445 | i64.add 446 | i32.wrap_i64 447 | i32.const 10 448 | i32.rem_u 449 | call $assembly/generator/getActualMode 450 | local.get $1 451 | call $assembly/generator/writeBlock 452 | local.get $1 453 | i64.const 1 454 | i64.add 455 | local.set $1 456 | br $for-loop|0 457 | end 458 | end 459 | i32.const 0 460 | ) 461 | ) 462 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bc6h-decoder-wasm", 3 | "version": "0.1.0", 4 | "description": "WebAssembly BC6H decoder.", 5 | "keywords": [ 6 | "gpu", 7 | "webgl", 8 | "wasm", 9 | "hdr", 10 | "bc6h", 11 | "texture", 12 | "ibl", 13 | "ktx", 14 | "dds" 15 | ], 16 | "author": "The Khronos Group, Inc.", 17 | "license": "Apache-2.0", 18 | "devDependencies": { 19 | "@types/node": "^14.14.7", 20 | "@typescript-eslint/eslint-plugin": "^4.7.0", 21 | "@typescript-eslint/parser": "^4.7.0", 22 | "assemblyscript": "0.17.2", 23 | "eslint": "^7.13.0", 24 | "eslint-plugin-unicorn": "^23.0.0", 25 | "tap-spec": "^5.0.0", 26 | "tape": "^5.0.1", 27 | "ts-node": "^9.0.0", 28 | "typescript": "^4.0.5" 29 | }, 30 | "scripts": { 31 | "asbuild:generator": "asc assembly/generator.ts -b build/generator.wasm -t build/generator.wat --optimize --converge --runtime none --noAssert --importMemory --memoryBase 63488", 32 | "asbuild:bc6hu-rgba16f": "asc assembly/decoder.ts -u MODE=0 -b build/bc6hu-rgba16f.wasm -t build/bc6hu-rgba16f.wat --optimize --converge --runtime none --noAssert --importMemory", 33 | "asbuild:bc6hu-rgb9e5": "asc assembly/decoder.ts -u MODE=1 -b build/bc6hu-rgb9e5.wasm -t build/bc6hu-rgb9e5.wat --optimize --converge --runtime none --noAssert --importMemory", 34 | "asbuild:bc6hu-r11fg11fb10f_round": "asc assembly/decoder.ts -u MODE=2 -b build/bc6hu-r11fg11fb10f_round.wasm -t build/bc6hu-r11fg11fb10f_round.wat --optimize --converge --runtime none --noAssert --importMemory", 35 | "asbuild:bc6hu-r11fg11fb10f_trunc": "asc assembly/decoder.ts -u MODE=3 -b build/bc6hu-r11fg11fb10f_trunc.wasm -t build/bc6hu-r11fg11fb10f_trunc.wat --optimize --converge --runtime none --noAssert --importMemory", 36 | "asbuild:bc6hu-r11fg11fb10f_round_noclamp": "asc assembly/decoder.ts -u MODE=4 -b build/bc6hu-r11fg11fb10f_round_noclamp.wasm -t build/bc6hu-r11fg11fb10f_round_noclamp.wat --optimize --converge --runtime none --noAssert --importMemory", 37 | "asbuild:bc6hu-rgb32f": "asc assembly/decoder.ts -u MODE=5 -b build/bc6hu-rgb32f.wasm -t build/bc6hu-rgb32f.wat --optimize --converge --runtime none --noAssert --importMemory", 38 | "asbuild:decoders": "npm run asbuild:bc6hu-rgba16f && npm run asbuild:bc6hu-rgb9e5 && npm run asbuild:bc6hu-r11fg11fb10f_round && npm run asbuild:bc6hu-r11fg11fb10f_trunc && npm run asbuild:bc6hu-r11fg11fb10f_round_noclamp && npm run asbuild:bc6hu-rgb32f", 39 | "asbuild": "npm run asbuild:generator && npm run asbuild:decoders", 40 | "test": "ts-node node_modules/tape/bin/tape test/test.ts | tap-spec" 41 | }, 42 | "eslintConfig": { 43 | "parser": "@typescript-eslint/parser", 44 | "plugins": [ 45 | "@typescript-eslint", 46 | "unicorn" 47 | ], 48 | "extends": [ 49 | "eslint:recommended", 50 | "plugin:@typescript-eslint/recommended" 51 | ], 52 | "rules": { 53 | "semi": "off", 54 | "@typescript-eslint/ban-ts-comment": "off", 55 | "@typescript-eslint/semi": [ 56 | "error", 57 | "always" 58 | ], 59 | "unicorn/number-literal-case": "error" 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test/test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Khronos Group Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | import * as fs from 'fs'; 6 | import * as test from 'tape'; 7 | import * as crypto from 'crypto'; 8 | 9 | const WIDTH = 8192; 10 | const HEIGHT = 8192; 11 | 12 | const modeChecksums = { 13 | "0": { 14 | bc6h: "63649c22a56e93a93fa2bbdb299e4410b7976054821bbd0e210a2ec2c59a329c", 15 | rgba16f: "a1d51f083201861f444e9b8507a1951ee9d9ba4c47d74692b38ee0c02f96a105" 16 | }, 17 | "1": { 18 | bc6h: "29ab9bb7069402defd5a359460cee351405a8431bb4a692d0e7a7745b43f648c", 19 | rgba16f: "b58bc9cb50894e18f7b4704056d9fedb8e54acba209524142b648a5dd3486042" 20 | }, 21 | "2": { 22 | bc6h: "b2cc06730141f23ff971ca958b16e46f9491a88a68a22278cb4b07e05065c1ee", 23 | rgba16f: "f81ac469bd5ab12354bbc22794468db7b4af394757080ba9a62e3760b48a06ce" 24 | }, 25 | "6": { 26 | bc6h: "6ea51e7f8b6366b9b2cba9ecf3f00723871db4633051e45bc7be2cbafe7f58bb", 27 | rgba16f: "c63e908242825bae8cbe4af54b0a3d72ccd3317c4d09557b928cf99363d39cdd" 28 | }, 29 | "10": { 30 | bc6h: "6abb7f59941cf7c291d8dbd4f673e57b8bd34e56fd3de949ea3af8eea5fda78d", 31 | rgba16f: "a25746a3a7af4387466afced1374f7d5e4602f4568a0de251f2159a9ce5846e9" 32 | }, 33 | "14": { 34 | bc6h: "a52128e835c314207b01e3f36776997b8285119bd08a4e1ff6a7b5ed5b4dec6c", 35 | rgba16f: "288af432a33380d446d0a07696ef74ddccd940b817323eef8cc6df507a94578e" 36 | }, 37 | "18": { 38 | bc6h: "854abcaadefb93a012cc448773ff2e5cb024ddcf6ee8024b6b8b6083ba4aed31", 39 | rgba16f: "7737f401427cc3f832023f8134776ee14080f0072945d9da5040ddd076fb4f30" 40 | }, 41 | "22": { 42 | bc6h: "9e246c47b0d727ff68c8d64befbcb552f5b3c2ec75a95cdf40909802a839c36a", 43 | rgba16f: "b48ef3a8fe1115fbfd963da20f5e169434faca323952beee75235cfabead6871" 44 | }, 45 | "26": { 46 | bc6h: "5ea960b0dcf4a30b11cb4cc077c31901a6794f00f9224814d638235f98bbdd86", 47 | rgba16f: "06611b8c45dcfa303a04c909ad8ee4094dfaf6916ed72b10ac2362290907e643" 48 | }, 49 | "30": { 50 | bc6h: "b7380d85abed2c190b085a2753b68fbcbf934cceba9931f8e98ea392c077e4cf", 51 | rgba16f: "23bb81a1c2f6fb4383940d0ee02bcd63ad93abb45b5a8c9f1691f8ad7f71be60" 52 | }, 53 | "3": { 54 | bc6h: "6f0eb1c28c0a0e27153a57e51072aa8c3ccb25c3d074dbc9fa45d10229455ecd", 55 | rgba16f: "97cb8255d41134e84941d9f7aadf32a62cbc7ad8514c67a88935a0eda671b3bb" 56 | }, 57 | "7": { 58 | bc6h: "b59924b592ab4316270535723bba79402752403a3d32585c5d7be0c6da82ff28", 59 | rgba16f: "08c718e02ecba0fca19fb26c64700c394ecb28af5320414baba068af614949a8" 60 | }, 61 | "11": { 62 | bc6h: "b025d88e5ea001a80c0b064e34db54870458bba6d0d5336414a1365dd7fe227d", 63 | rgba16f: "8768db1e1fe91eac80cecc468836f85c76aefee84916f08fe8dbe8abf7f4ef0a" 64 | }, 65 | "15": { 66 | bc6h: "9d5ac6f01bde258e50bc148f9f9b78e67048b69d01941e19b28c09e23ee3869c", 67 | rgba16f: "0fe336c72371ccb581f63eeb6bda3d8cf47f81e24bd83b4453872290742bcde6" 68 | }, 69 | "19": { 70 | bc6h: "c5cbb95e965585bea4f8d728f0be403f3ab3ac5bcc1ab5f9c22e940e7714a70c", 71 | rgba16f: "8c7671118d7035c6f82e6931252131eeea6eab91420a0dbae085a07583c1e9dc" 72 | }, 73 | "23": { 74 | bc6h: "8a4a88a4c72bf2b36a1b189edb1967655be370e14c4769d646605b61e73c3b89", 75 | rgba16f: "8c7671118d7035c6f82e6931252131eeea6eab91420a0dbae085a07583c1e9dc" 76 | }, 77 | "27": { 78 | bc6h: "486e4077750cd16a302b91766d41d736905e14c62881bf65548e347f6ba845a8", 79 | rgba16f: "8c7671118d7035c6f82e6931252131eeea6eab91420a0dbae085a07583c1e9dc" 80 | }, 81 | "31": { 82 | bc6h: "3cef1e895be8b66113efb4118ce1883747a72dc171782496480f281843d8bdd5", 83 | rgba16f: "8c7671118d7035c6f82e6931252131eeea6eab91420a0dbae085a07583c1e9dc" 84 | } 85 | }; 86 | 87 | const mixedChecksums = { 88 | full: { 89 | bc6h: "18009f7b34482248ef27b4d5174bfdd954a5ba870533256ffb833cd1eaa5634a", 90 | rgba16f: "622ab1e1310dc41b5bee667a0702339221836008309d6f545c74a0a91e1b5c0b", 91 | rgb9e5: "8a20f895bbb62b8a7f77395de12229dceaf1ee7925e540502c0eb9347a3379e3", 92 | r11fg11fb10f_round: "1dc0848c6402bbd3d02d4320c1ae2e28933b5fde86c5368ac892b6aa16603d26", 93 | r11fg11fb10f_trunc: "7bfe0f27fac13e4da4f743818f6bdb788e9270f5055805432aee6ee510c7b846", 94 | r11fg11fb10f_round_noclamp: "a8c5064bcd734997bc2fd939bc80a23ef471d4232134d888c0c9e0b76fe9cc6a", 95 | rgb32f: "1f2d03bdb24c9852d8b0dffabb6c96da97c7a8113ec895d2419d015dc6d0747f" 96 | }, 97 | cropped: { 98 | bc6h: "18009f7b34482248ef27b4d5174bfdd954a5ba870533256ffb833cd1eaa5634a", 99 | rgba16f: "ab643e8bee38b859575f23a229631bf7f05f297831d50eaa8cd2c79edbd5b611", 100 | rgb9e5: "1f71648a5af72ef3a74014e41c0dd413612047cc7c1f264d684163cf81536c12", 101 | r11fg11fb10f_round: "86c58b5e24143e44d27cdbf7ff4da355c7e51451eaadc7b9dbd7eff70c3aae58", 102 | r11fg11fb10f_trunc: "f33b6cff8fe1591d343a00696d4fbc4a1aa028875d1db95cc42071df5b9ac91b", 103 | r11fg11fb10f_round_noclamp: "2b9776757999429027bdb28b6ca8797680d4415108464fa3cf1d5cecc2d7f7f6", 104 | rgb32f: "58a1d1a7fb0fa22e661fa4b9f0b5ca827dafdc11f27684f77738b1793444170f" 105 | } 106 | }; 107 | 108 | let numBlocks: number; 109 | let compressedView: Uint8Array; 110 | let uncompressedView: Uint8Array; 111 | 112 | let generator: IGenerator; 113 | 114 | const kUserDataOffset = 65536; 115 | 116 | async function setup(wasmPath: string, pixelSize: number, width = WIDTH, height = HEIGHT): Promise { 117 | const yBlocks = ((height + 3) >> 2); 118 | numBlocks = ((width + 3) >> 2) * yBlocks; 119 | 120 | const compressedByteLength = numBlocks * 16; 121 | const uncompressedByteLength = width * height * pixelSize; 122 | const totalByteLength = compressedByteLength + width * (4 * yBlocks) * pixelSize; 123 | const memory = new WebAssembly.Memory({ initial: (kUserDataOffset + totalByteLength + 65535) >> 16 }); 124 | 125 | compressedView = new Uint8Array(memory.buffer, kUserDataOffset, compressedByteLength); 126 | uncompressedView = new Uint8Array(memory.buffer, kUserDataOffset + compressedByteLength, uncompressedByteLength); 127 | 128 | // Generator 129 | const generatorModule = new WebAssembly.Module(fs.readFileSync('build/generator.wasm')); 130 | generator = new WebAssembly.Instance(generatorModule, { env: { memory: memory } }).exports as unknown as IGenerator; 131 | 132 | // Decoder 133 | const module = new WebAssembly.Module(fs.readFileSync(wasmPath)); 134 | return new WebAssembly.Instance(module, { env: { memory: memory } }).exports as unknown as IDecoder; 135 | } 136 | 137 | test('Individual Modes, RGBA16F', async (t) => { 138 | const decoder = await setup('build/bc6hu-rgba16f.wasm', 8); 139 | 140 | for (let m = 0; m < 18; m++) { 141 | const mode = generator.generate(m, numBlocks); 142 | const hashes = modeChecksums[mode.toString()]; 143 | 144 | const genHash = crypto.createHash('sha256').update(compressedView).digest('hex'); 145 | t.equals(genHash, hashes.bc6h, `mode ${mode.toString().padStart(2, '0')}: generator`); 146 | 147 | decoder.decode(WIDTH, HEIGHT); 148 | const decHash = crypto.createHash('sha256').update(uncompressedView).digest('hex'); 149 | t.equals(decHash, hashes.rgba16f, `mode ${mode.toString().padStart(2, '0')}: decoder`); 150 | } 151 | 152 | t.end(); 153 | }); 154 | 155 | test('Mixed Modes', async (t) => { 156 | const modules = { 157 | rgba16f: 8, 158 | rgb9e5: 4, 159 | r11fg11fb10f_round: 4, 160 | r11fg11fb10f_trunc: 4, 161 | r11fg11fb10f_round_noclamp: 4, 162 | rgb32f: 12 163 | }; 164 | 165 | for (const module in modules) { 166 | const pixelSize = modules[module]; 167 | const decoder = await setup(`build/bc6hu-${module}.wasm`, pixelSize); 168 | 169 | generator.generateAll(numBlocks); 170 | const hashes = mixedChecksums.full; 171 | 172 | const genHash = crypto.createHash('sha256').update(compressedView).digest('hex'); 173 | t.equals(genHash, hashes.bc6h, `all modes: generator`); 174 | 175 | decoder.decode(WIDTH, HEIGHT); 176 | const decHash = crypto.createHash('sha256').update(uncompressedView).digest('hex'); 177 | t.equals(decHash, hashes[module], `all modes: ${module} decoder`); 178 | } 179 | 180 | t.end(); 181 | }); 182 | 183 | test('Mixed Modes - odd dimensions', async (t) => { 184 | const modules = { 185 | rgba16f: 8, 186 | rgb9e5: 4, 187 | r11fg11fb10f_round: 4, 188 | r11fg11fb10f_trunc: 4, 189 | r11fg11fb10f_round_noclamp: 4, 190 | rgb32f: 12 191 | }; 192 | 193 | for (const module in modules) { 194 | const pixelSize = modules[module]; 195 | const decoder = await setup(`build/bc6hu-${module}.wasm`, pixelSize, WIDTH - 1, HEIGHT - 1); 196 | 197 | generator.generateAll(numBlocks); 198 | const hashes = mixedChecksums.cropped; 199 | 200 | const genHash = crypto.createHash('sha256').update(compressedView).digest('hex'); 201 | t.equals(genHash, hashes.bc6h, `all modes: generator`); 202 | 203 | decoder.decode(WIDTH - 1, HEIGHT - 1); 204 | const decHash = crypto.createHash('sha256').update(uncompressedView).digest('hex'); 205 | t.equals(decHash, hashes[module], `all modes: ${module} decoder`); 206 | } 207 | 208 | t.end(); 209 | }); 210 | 211 | interface IDecoder { 212 | decode(width: number, height: number): number; 213 | } 214 | 215 | interface IGenerator { 216 | generate(mode: number, nBlocks: number): number; 217 | generateAll(nBlocks: number): number; 218 | } --------------------------------------------------------------------------------