Path: blob/master/thirdparty/cvtt/ConvectionKernels_BC6H_IO.cpp
9902 views
/*1Convection Texture Tools2Copyright (c) 2018-2019 Eric Lasota34Permission is hereby granted, free of charge, to any person obtaining5a copy of this software and associated documentation files (the6"Software"), to deal in the Software without restriction, including7without limitation the rights to use, copy, modify, merge, publish,8distribute, sublicense, and/or sell copies of the Software, and to9permit persons to whom the Software is furnished to do so, subject10to the following conditions:1112The above copyright notice and this permission notice shall be included13in all copies or substantial portions of the Software.1415THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS16OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF17MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.18IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY19CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,20TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE21SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2223-------------------------------------------------------------------------------------2425Portions based on DirectX Texture Library (DirectXTex)2627Copyright (c) Microsoft Corporation. All rights reserved.28Licensed under the MIT License.2930http://go.microsoft.com/fwlink/?LinkId=24892631*/32#include "ConvectionKernels_Config.h"3334#if !defined(CVTT_SINGLE_FILE) || defined(CVTT_SINGLE_FILE_IMPL)3536#include "ConvectionKernels_BC6H_IO.h"3738namespace cvtt39{40namespace BC6H_IO41{42void WriteMode0(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)43{44encoded[0] = (m & 0x3u) | ((gy >> 2) & 0x4u) | ((by >> 1) & 0x8u) | (bz & 0x10u) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);45encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0xf8u) | ((gz << 4) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x3e000u) | ((bz << 18) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0xf800000u) | ((bz << 27) & 0x10000000u) | ((by << 29) & 0xe0000000u);46encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x3eu) | ((bz << 4) & 0x40u) | ((rz << 7) & 0xf80u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);47}4849void WriteMode1(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)50{51encoded[0] = (m & 0x3u) | ((gy >> 3) & 0x4u) | ((gz >> 1) & 0x18u) | ((rw << 5) & 0xfe0u) | ((bz << 12) & 0x3000u) | ((by << 10) & 0x4000u) | ((gw << 15) & 0x3f8000u) | ((by << 17) & 0x400000u) | ((bz << 21) & 0x800000u) | ((gy << 20) & 0x1000000u) | ((bw << 25) & 0xfe000000u);52encoded[1] = ((bz >> 3) & 0x1u) | ((bz >> 4) & 0x2u) | ((bz >> 2) & 0x4u) | ((rx << 3) & 0x1f8u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x7e000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0x1f800000u) | ((by << 29) & 0xe0000000u);53encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x7eu) | ((rz << 7) & 0x1f80u) | ((d << 13) & 0x3e000u);54}5556void WriteMode2(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)57{58encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);59encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0xf8u) | ((rw >> 2) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x1e000u) | ((gw << 7) & 0x20000u) | ((bz << 18) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0x7800000u) | ((bw << 17) & 0x8000000u) | ((bz << 27) & 0x10000000u) | ((by << 29) & 0xe0000000u);60encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x3eu) | ((bz << 4) & 0x40u) | ((rz << 7) & 0xf80u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);61}6263void WriteMode3(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)64{65encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);66encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0x78u) | ((rw >> 3) & 0x80u) | ((gz << 4) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x3e000u) | ((gw << 8) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0x7800000u) | ((bw << 17) & 0x8000000u) | ((bz << 27) & 0x10000000u) | ((by << 29) & 0xe0000000u);67encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x1eu) | ((bz << 5) & 0x20u) | ((bz << 4) & 0x40u) | ((rz << 7) & 0x780u) | ((gy << 7) & 0x800u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);68}6970void WriteMode4(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)71{72encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);73encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0x78u) | ((rw >> 3) & 0x80u) | ((by << 4) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x1e000u) | ((gw << 7) & 0x20000u) | ((bz << 18) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0xf800000u) | ((bw << 18) & 0x10000000u) | ((by << 29) & 0xe0000000u);74encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x1eu) | ((bz << 4) & 0x60u) | ((rz << 7) & 0x780u) | ((bz << 7) & 0x800u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);75}7677void WriteMode5(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)78{79encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x3fe0u) | ((by << 10) & 0x4000u) | ((gw << 15) & 0xff8000u) | ((gy << 20) & 0x1000000u) | ((bw << 25) & 0xfe000000u);80encoded[1] = ((bw >> 7) & 0x3u) | ((bz >> 2) & 0x4u) | ((rx << 3) & 0xf8u) | ((gz << 4) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x3e000u) | ((bz << 18) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0xf800000u) | ((bz << 27) & 0x10000000u) | ((by << 29) & 0xe0000000u);81encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x3eu) | ((bz << 4) & 0x40u) | ((rz << 7) & 0xf80u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);82}8384void WriteMode6(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)85{86encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x1fe0u) | ((gz << 9) & 0x2000u) | ((by << 10) & 0x4000u) | ((gw << 15) & 0x7f8000u) | ((bz << 21) & 0x800000u) | ((gy << 20) & 0x1000000u) | ((bw << 25) & 0xfe000000u);87encoded[1] = ((bw >> 7) & 0x1u) | ((bz >> 2) & 0x6u) | ((rx << 3) & 0x1f8u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x3e000u) | ((bz << 18) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0xf800000u) | ((bz << 27) & 0x10000000u) | ((by << 29) & 0xe0000000u);88encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x7eu) | ((rz << 7) & 0x1f80u) | ((d << 13) & 0x3e000u);89}9091void WriteMode7(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)92{93encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x1fe0u) | ((bz << 13) & 0x2000u) | ((by << 10) & 0x4000u) | ((gw << 15) & 0x7f8000u) | ((gy << 18) & 0x800000u) | ((gy << 20) & 0x1000000u) | ((bw << 25) & 0xfe000000u);94encoded[1] = ((bw >> 7) & 0x1u) | ((gz >> 4) & 0x2u) | ((bz >> 2) & 0x4u) | ((rx << 3) & 0xf8u) | ((gz << 4) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x7e000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0xf800000u) | ((bz << 27) & 0x10000000u) | ((by << 29) & 0xe0000000u);95encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x3eu) | ((bz << 4) & 0x40u) | ((rz << 7) & 0xf80u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);96}9798void WriteMode8(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)99{100encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x1fe0u) | ((bz << 12) & 0x2000u) | ((by << 10) & 0x4000u) | ((gw << 15) & 0x7f8000u) | ((by << 18) & 0x800000u) | ((gy << 20) & 0x1000000u) | ((bw << 25) & 0xfe000000u);101encoded[1] = ((bw >> 7) & 0x1u) | ((bz >> 4) & 0x2u) | ((bz >> 2) & 0x4u) | ((rx << 3) & 0xf8u) | ((gz << 4) & 0x100u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x3e000u) | ((bz << 18) & 0x40000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0x1f800000u) | ((by << 29) & 0xe0000000u);102encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x3eu) | ((bz << 4) & 0x40u) | ((rz << 7) & 0xf80u) | ((bz << 9) & 0x1000u) | ((d << 13) & 0x3e000u);103}104105void WriteMode9(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)106{107encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7e0u) | ((gz << 7) & 0x800u) | ((bz << 12) & 0x3000u) | ((by << 10) & 0x4000u) | ((gw << 15) & 0x1f8000u) | ((gy << 16) & 0x200000u) | ((by << 17) & 0x400000u) | ((bz << 21) & 0x800000u) | ((gy << 20) & 0x1000000u) | ((bw << 25) & 0x7e000000u) | ((gz << 26) & 0x80000000u);108encoded[1] = ((bz >> 3) & 0x1u) | ((bz >> 4) & 0x2u) | ((bz >> 2) & 0x4u) | ((rx << 3) & 0x1f8u) | ((gy << 9) & 0x1e00u) | ((gx << 13) & 0x7e000u) | ((gz << 19) & 0x780000u) | ((bx << 23) & 0x1f800000u) | ((by << 29) & 0xe0000000u);109encoded[2] = ((by >> 3) & 0x1u) | ((ry << 1) & 0x7eu) | ((rz << 7) & 0x1f80u) | ((d << 13) & 0x3e000u);110}111112void WriteMode10(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)113{114encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);115encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0x1ff8u) | ((gx << 13) & 0x7fe000u) | ((bx << 23) & 0xff800000u);116encoded[2] = ((bx >> 9) & 0x1u);117}118119void WriteMode11(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)120{121encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);122encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0xff8u) | ((rw << 2) & 0x1000u) | ((gx << 13) & 0x3fe000u) | ((gw << 12) & 0x400000u) | ((bx << 23) & 0xff800000u);123encoded[2] = ((bw >> 10) & 0x1u);124}125126void WriteMode12(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)127{128encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);129encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0x7f8u) | (rw & 0x800u) | ((rw << 2) & 0x1000u) | ((gx << 13) & 0x1fe000u) | ((gw << 10) & 0x200000u) | ((gw << 12) & 0x400000u) | ((bx << 23) & 0x7f800000u) | ((bw << 20) & 0x80000000u);130encoded[2] = ((bw >> 10) & 0x1u);131}132133void WriteMode13(uint32_t *encoded, uint16_t m, uint16_t d, uint16_t rw, uint16_t rx, uint16_t ry, uint16_t rz, uint16_t gw, uint16_t gx, uint16_t gy, uint16_t gz, uint16_t bw, uint16_t bx, uint16_t by, uint16_t bz)134{135encoded[0] = (m & 0x1fu) | ((rw << 5) & 0x7fe0u) | ((gw << 15) & 0x1ff8000u) | ((bw << 25) & 0xfe000000u);136encoded[1] = ((bw >> 7) & 0x7u) | ((rx << 3) & 0x78u) | ((rw >> 8) & 0x80u) | ((rw >> 6) & 0x100u) | ((rw >> 4) & 0x200u) | ((rw >> 2) & 0x400u) | (rw & 0x800u) | ((rw << 2) & 0x1000u) | ((gx << 13) & 0x1e000u) | ((gw << 2) & 0x20000u) | ((gw << 4) & 0x40000u) | ((gw << 6) & 0x80000u) | ((gw << 8) & 0x100000u) | ((gw << 10) & 0x200000u) | ((gw << 12) & 0x400000u) | ((bx << 23) & 0x7800000u) | ((bw << 12) & 0x8000000u) | ((bw << 14) & 0x10000000u) | ((bw << 16) & 0x20000000u) | ((bw << 18) & 0x40000000u) | ((bw << 20) & 0x80000000u);137encoded[2] = ((bw >> 10) & 0x1u);138}139140void ReadMode0(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)141{142uint16_t d = 0;143uint16_t rw = 0;144uint16_t rx = 0;145uint16_t ry = 0;146uint16_t rz = 0;147uint16_t gw = 0;148uint16_t gx = 0;149uint16_t gy = 0;150uint16_t gz = 0;151uint16_t bw = 0;152uint16_t bx = 0;153uint16_t by = 0;154uint16_t bz = 0;155gy |= ((encoded[0] << 2) & 0x10u);156by |= ((encoded[0] << 1) & 0x10u);157bz |= (encoded[0] & 0x10u);158rw |= ((encoded[0] >> 5) & 0x3ffu);159gw |= ((encoded[0] >> 15) & 0x3ffu);160bw |= ((encoded[0] >> 25) & 0x7fu);161bw |= ((encoded[1] << 7) & 0x380u);162rx |= ((encoded[1] >> 3) & 0x1fu);163gz |= ((encoded[1] >> 4) & 0x10u);164gy |= ((encoded[1] >> 9) & 0xfu);165gx |= ((encoded[1] >> 13) & 0x1fu);166bz |= ((encoded[1] >> 18) & 0x1u);167gz |= ((encoded[1] >> 19) & 0xfu);168bx |= ((encoded[1] >> 23) & 0x1fu);169bz |= ((encoded[1] >> 27) & 0x2u);170by |= ((encoded[1] >> 29) & 0x7u);171by |= ((encoded[2] << 3) & 0x8u);172ry |= ((encoded[2] >> 1) & 0x1fu);173bz |= ((encoded[2] >> 4) & 0x4u);174rz |= ((encoded[2] >> 7) & 0x1fu);175bz |= ((encoded[2] >> 9) & 0x8u);176d |= ((encoded[2] >> 13) & 0x1fu);177outD = d;178outRW = rw;179outRX = rx;180outRY = ry;181outRZ = rz;182outGW = gw;183outGX = gx;184outGY = gy;185outGZ = gz;186outBW = bw;187outBX = bx;188outBY = by;189outBZ = bz;190}191192void ReadMode1(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)193{194uint16_t d = 0;195uint16_t rw = 0;196uint16_t rx = 0;197uint16_t ry = 0;198uint16_t rz = 0;199uint16_t gw = 0;200uint16_t gx = 0;201uint16_t gy = 0;202uint16_t gz = 0;203uint16_t bw = 0;204uint16_t bx = 0;205uint16_t by = 0;206uint16_t bz = 0;207gy |= ((encoded[0] << 3) & 0x20u);208gz |= ((encoded[0] << 1) & 0x30u);209rw |= ((encoded[0] >> 5) & 0x7fu);210bz |= ((encoded[0] >> 12) & 0x3u);211by |= ((encoded[0] >> 10) & 0x10u);212gw |= ((encoded[0] >> 15) & 0x7fu);213by |= ((encoded[0] >> 17) & 0x20u);214bz |= ((encoded[0] >> 21) & 0x4u);215gy |= ((encoded[0] >> 20) & 0x10u);216bw |= ((encoded[0] >> 25) & 0x7fu);217bz |= ((encoded[1] << 3) & 0x8u);218bz |= ((encoded[1] << 4) & 0x20u);219bz |= ((encoded[1] << 2) & 0x10u);220rx |= ((encoded[1] >> 3) & 0x3fu);221gy |= ((encoded[1] >> 9) & 0xfu);222gx |= ((encoded[1] >> 13) & 0x3fu);223gz |= ((encoded[1] >> 19) & 0xfu);224bx |= ((encoded[1] >> 23) & 0x3fu);225by |= ((encoded[1] >> 29) & 0x7u);226by |= ((encoded[2] << 3) & 0x8u);227ry |= ((encoded[2] >> 1) & 0x3fu);228rz |= ((encoded[2] >> 7) & 0x3fu);229d |= ((encoded[2] >> 13) & 0x1fu);230outD = d;231outRW = rw;232outRX = rx;233outRY = ry;234outRZ = rz;235outGW = gw;236outGX = gx;237outGY = gy;238outGZ = gz;239outBW = bw;240outBX = bx;241outBY = by;242outBZ = bz;243}244245void ReadMode2(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)246{247uint16_t d = 0;248uint16_t rw = 0;249uint16_t rx = 0;250uint16_t ry = 0;251uint16_t rz = 0;252uint16_t gw = 0;253uint16_t gx = 0;254uint16_t gy = 0;255uint16_t gz = 0;256uint16_t bw = 0;257uint16_t bx = 0;258uint16_t by = 0;259uint16_t bz = 0;260rw |= ((encoded[0] >> 5) & 0x3ffu);261gw |= ((encoded[0] >> 15) & 0x3ffu);262bw |= ((encoded[0] >> 25) & 0x7fu);263bw |= ((encoded[1] << 7) & 0x380u);264rx |= ((encoded[1] >> 3) & 0x1fu);265rw |= ((encoded[1] << 2) & 0x400u);266gy |= ((encoded[1] >> 9) & 0xfu);267gx |= ((encoded[1] >> 13) & 0xfu);268gw |= ((encoded[1] >> 7) & 0x400u);269bz |= ((encoded[1] >> 18) & 0x1u);270gz |= ((encoded[1] >> 19) & 0xfu);271bx |= ((encoded[1] >> 23) & 0xfu);272bw |= ((encoded[1] >> 17) & 0x400u);273bz |= ((encoded[1] >> 27) & 0x2u);274by |= ((encoded[1] >> 29) & 0x7u);275by |= ((encoded[2] << 3) & 0x8u);276ry |= ((encoded[2] >> 1) & 0x1fu);277bz |= ((encoded[2] >> 4) & 0x4u);278rz |= ((encoded[2] >> 7) & 0x1fu);279bz |= ((encoded[2] >> 9) & 0x8u);280d |= ((encoded[2] >> 13) & 0x1fu);281outD = d;282outRW = rw;283outRX = rx;284outRY = ry;285outRZ = rz;286outGW = gw;287outGX = gx;288outGY = gy;289outGZ = gz;290outBW = bw;291outBX = bx;292outBY = by;293outBZ = bz;294}295296void ReadMode3(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)297{298uint16_t d = 0;299uint16_t rw = 0;300uint16_t rx = 0;301uint16_t ry = 0;302uint16_t rz = 0;303uint16_t gw = 0;304uint16_t gx = 0;305uint16_t gy = 0;306uint16_t gz = 0;307uint16_t bw = 0;308uint16_t bx = 0;309uint16_t by = 0;310uint16_t bz = 0;311rw |= ((encoded[0] >> 5) & 0x3ffu);312gw |= ((encoded[0] >> 15) & 0x3ffu);313bw |= ((encoded[0] >> 25) & 0x7fu);314bw |= ((encoded[1] << 7) & 0x380u);315rx |= ((encoded[1] >> 3) & 0xfu);316rw |= ((encoded[1] << 3) & 0x400u);317gz |= ((encoded[1] >> 4) & 0x10u);318gy |= ((encoded[1] >> 9) & 0xfu);319gx |= ((encoded[1] >> 13) & 0x1fu);320gw |= ((encoded[1] >> 8) & 0x400u);321gz |= ((encoded[1] >> 19) & 0xfu);322bx |= ((encoded[1] >> 23) & 0xfu);323bw |= ((encoded[1] >> 17) & 0x400u);324bz |= ((encoded[1] >> 27) & 0x2u);325by |= ((encoded[1] >> 29) & 0x7u);326by |= ((encoded[2] << 3) & 0x8u);327ry |= ((encoded[2] >> 1) & 0xfu);328bz |= ((encoded[2] >> 5) & 0x1u);329bz |= ((encoded[2] >> 4) & 0x4u);330rz |= ((encoded[2] >> 7) & 0xfu);331gy |= ((encoded[2] >> 7) & 0x10u);332bz |= ((encoded[2] >> 9) & 0x8u);333d |= ((encoded[2] >> 13) & 0x1fu);334outD = d;335outRW = rw;336outRX = rx;337outRY = ry;338outRZ = rz;339outGW = gw;340outGX = gx;341outGY = gy;342outGZ = gz;343outBW = bw;344outBX = bx;345outBY = by;346outBZ = bz;347}348349void ReadMode4(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)350{351uint16_t d = 0;352uint16_t rw = 0;353uint16_t rx = 0;354uint16_t ry = 0;355uint16_t rz = 0;356uint16_t gw = 0;357uint16_t gx = 0;358uint16_t gy = 0;359uint16_t gz = 0;360uint16_t bw = 0;361uint16_t bx = 0;362uint16_t by = 0;363uint16_t bz = 0;364rw |= ((encoded[0] >> 5) & 0x3ffu);365gw |= ((encoded[0] >> 15) & 0x3ffu);366bw |= ((encoded[0] >> 25) & 0x7fu);367bw |= ((encoded[1] << 7) & 0x380u);368rx |= ((encoded[1] >> 3) & 0xfu);369rw |= ((encoded[1] << 3) & 0x400u);370by |= ((encoded[1] >> 4) & 0x10u);371gy |= ((encoded[1] >> 9) & 0xfu);372gx |= ((encoded[1] >> 13) & 0xfu);373gw |= ((encoded[1] >> 7) & 0x400u);374bz |= ((encoded[1] >> 18) & 0x1u);375gz |= ((encoded[1] >> 19) & 0xfu);376bx |= ((encoded[1] >> 23) & 0x1fu);377bw |= ((encoded[1] >> 18) & 0x400u);378by |= ((encoded[1] >> 29) & 0x7u);379by |= ((encoded[2] << 3) & 0x8u);380ry |= ((encoded[2] >> 1) & 0xfu);381bz |= ((encoded[2] >> 4) & 0x6u);382rz |= ((encoded[2] >> 7) & 0xfu);383bz |= ((encoded[2] >> 7) & 0x10u);384bz |= ((encoded[2] >> 9) & 0x8u);385d |= ((encoded[2] >> 13) & 0x1fu);386outD = d;387outRW = rw;388outRX = rx;389outRY = ry;390outRZ = rz;391outGW = gw;392outGX = gx;393outGY = gy;394outGZ = gz;395outBW = bw;396outBX = bx;397outBY = by;398outBZ = bz;399}400401void ReadMode5(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)402{403uint16_t d = 0;404uint16_t rw = 0;405uint16_t rx = 0;406uint16_t ry = 0;407uint16_t rz = 0;408uint16_t gw = 0;409uint16_t gx = 0;410uint16_t gy = 0;411uint16_t gz = 0;412uint16_t bw = 0;413uint16_t bx = 0;414uint16_t by = 0;415uint16_t bz = 0;416rw |= ((encoded[0] >> 5) & 0x1ffu);417by |= ((encoded[0] >> 10) & 0x10u);418gw |= ((encoded[0] >> 15) & 0x1ffu);419gy |= ((encoded[0] >> 20) & 0x10u);420bw |= ((encoded[0] >> 25) & 0x7fu);421bw |= ((encoded[1] << 7) & 0x180u);422bz |= ((encoded[1] << 2) & 0x10u);423rx |= ((encoded[1] >> 3) & 0x1fu);424gz |= ((encoded[1] >> 4) & 0x10u);425gy |= ((encoded[1] >> 9) & 0xfu);426gx |= ((encoded[1] >> 13) & 0x1fu);427bz |= ((encoded[1] >> 18) & 0x1u);428gz |= ((encoded[1] >> 19) & 0xfu);429bx |= ((encoded[1] >> 23) & 0x1fu);430bz |= ((encoded[1] >> 27) & 0x2u);431by |= ((encoded[1] >> 29) & 0x7u);432by |= ((encoded[2] << 3) & 0x8u);433ry |= ((encoded[2] >> 1) & 0x1fu);434bz |= ((encoded[2] >> 4) & 0x4u);435rz |= ((encoded[2] >> 7) & 0x1fu);436bz |= ((encoded[2] >> 9) & 0x8u);437d |= ((encoded[2] >> 13) & 0x1fu);438outD = d;439outRW = rw;440outRX = rx;441outRY = ry;442outRZ = rz;443outGW = gw;444outGX = gx;445outGY = gy;446outGZ = gz;447outBW = bw;448outBX = bx;449outBY = by;450outBZ = bz;451}452453void ReadMode6(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)454{455uint16_t d = 0;456uint16_t rw = 0;457uint16_t rx = 0;458uint16_t ry = 0;459uint16_t rz = 0;460uint16_t gw = 0;461uint16_t gx = 0;462uint16_t gy = 0;463uint16_t gz = 0;464uint16_t bw = 0;465uint16_t bx = 0;466uint16_t by = 0;467uint16_t bz = 0;468rw |= ((encoded[0] >> 5) & 0xffu);469gz |= ((encoded[0] >> 9) & 0x10u);470by |= ((encoded[0] >> 10) & 0x10u);471gw |= ((encoded[0] >> 15) & 0xffu);472bz |= ((encoded[0] >> 21) & 0x4u);473gy |= ((encoded[0] >> 20) & 0x10u);474bw |= ((encoded[0] >> 25) & 0x7fu);475bw |= ((encoded[1] << 7) & 0x80u);476bz |= ((encoded[1] << 2) & 0x18u);477rx |= ((encoded[1] >> 3) & 0x3fu);478gy |= ((encoded[1] >> 9) & 0xfu);479gx |= ((encoded[1] >> 13) & 0x1fu);480bz |= ((encoded[1] >> 18) & 0x1u);481gz |= ((encoded[1] >> 19) & 0xfu);482bx |= ((encoded[1] >> 23) & 0x1fu);483bz |= ((encoded[1] >> 27) & 0x2u);484by |= ((encoded[1] >> 29) & 0x7u);485by |= ((encoded[2] << 3) & 0x8u);486ry |= ((encoded[2] >> 1) & 0x3fu);487rz |= ((encoded[2] >> 7) & 0x3fu);488d |= ((encoded[2] >> 13) & 0x1fu);489outD = d;490outRW = rw;491outRX = rx;492outRY = ry;493outRZ = rz;494outGW = gw;495outGX = gx;496outGY = gy;497outGZ = gz;498outBW = bw;499outBX = bx;500outBY = by;501outBZ = bz;502}503504void ReadMode7(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)505{506uint16_t d = 0;507uint16_t rw = 0;508uint16_t rx = 0;509uint16_t ry = 0;510uint16_t rz = 0;511uint16_t gw = 0;512uint16_t gx = 0;513uint16_t gy = 0;514uint16_t gz = 0;515uint16_t bw = 0;516uint16_t bx = 0;517uint16_t by = 0;518uint16_t bz = 0;519rw |= ((encoded[0] >> 5) & 0xffu);520bz |= ((encoded[0] >> 13) & 0x1u);521by |= ((encoded[0] >> 10) & 0x10u);522gw |= ((encoded[0] >> 15) & 0xffu);523gy |= ((encoded[0] >> 18) & 0x20u);524gy |= ((encoded[0] >> 20) & 0x10u);525bw |= ((encoded[0] >> 25) & 0x7fu);526bw |= ((encoded[1] << 7) & 0x80u);527gz |= ((encoded[1] << 4) & 0x20u);528bz |= ((encoded[1] << 2) & 0x10u);529rx |= ((encoded[1] >> 3) & 0x1fu);530gz |= ((encoded[1] >> 4) & 0x10u);531gy |= ((encoded[1] >> 9) & 0xfu);532gx |= ((encoded[1] >> 13) & 0x3fu);533gz |= ((encoded[1] >> 19) & 0xfu);534bx |= ((encoded[1] >> 23) & 0x1fu);535bz |= ((encoded[1] >> 27) & 0x2u);536by |= ((encoded[1] >> 29) & 0x7u);537by |= ((encoded[2] << 3) & 0x8u);538ry |= ((encoded[2] >> 1) & 0x1fu);539bz |= ((encoded[2] >> 4) & 0x4u);540rz |= ((encoded[2] >> 7) & 0x1fu);541bz |= ((encoded[2] >> 9) & 0x8u);542d |= ((encoded[2] >> 13) & 0x1fu);543outD = d;544outRW = rw;545outRX = rx;546outRY = ry;547outRZ = rz;548outGW = gw;549outGX = gx;550outGY = gy;551outGZ = gz;552outBW = bw;553outBX = bx;554outBY = by;555outBZ = bz;556}557558void ReadMode8(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)559{560uint16_t d = 0;561uint16_t rw = 0;562uint16_t rx = 0;563uint16_t ry = 0;564uint16_t rz = 0;565uint16_t gw = 0;566uint16_t gx = 0;567uint16_t gy = 0;568uint16_t gz = 0;569uint16_t bw = 0;570uint16_t bx = 0;571uint16_t by = 0;572uint16_t bz = 0;573rw |= ((encoded[0] >> 5) & 0xffu);574bz |= ((encoded[0] >> 12) & 0x2u);575by |= ((encoded[0] >> 10) & 0x10u);576gw |= ((encoded[0] >> 15) & 0xffu);577by |= ((encoded[0] >> 18) & 0x20u);578gy |= ((encoded[0] >> 20) & 0x10u);579bw |= ((encoded[0] >> 25) & 0x7fu);580bw |= ((encoded[1] << 7) & 0x80u);581bz |= ((encoded[1] << 4) & 0x20u);582bz |= ((encoded[1] << 2) & 0x10u);583rx |= ((encoded[1] >> 3) & 0x1fu);584gz |= ((encoded[1] >> 4) & 0x10u);585gy |= ((encoded[1] >> 9) & 0xfu);586gx |= ((encoded[1] >> 13) & 0x1fu);587bz |= ((encoded[1] >> 18) & 0x1u);588gz |= ((encoded[1] >> 19) & 0xfu);589bx |= ((encoded[1] >> 23) & 0x3fu);590by |= ((encoded[1] >> 29) & 0x7u);591by |= ((encoded[2] << 3) & 0x8u);592ry |= ((encoded[2] >> 1) & 0x1fu);593bz |= ((encoded[2] >> 4) & 0x4u);594rz |= ((encoded[2] >> 7) & 0x1fu);595bz |= ((encoded[2] >> 9) & 0x8u);596d |= ((encoded[2] >> 13) & 0x1fu);597outD = d;598outRW = rw;599outRX = rx;600outRY = ry;601outRZ = rz;602outGW = gw;603outGX = gx;604outGY = gy;605outGZ = gz;606outBW = bw;607outBX = bx;608outBY = by;609outBZ = bz;610}611612void ReadMode9(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)613{614uint16_t d = 0;615uint16_t rw = 0;616uint16_t rx = 0;617uint16_t ry = 0;618uint16_t rz = 0;619uint16_t gw = 0;620uint16_t gx = 0;621uint16_t gy = 0;622uint16_t gz = 0;623uint16_t bw = 0;624uint16_t bx = 0;625uint16_t by = 0;626uint16_t bz = 0;627rw |= ((encoded[0] >> 5) & 0x3fu);628gz |= ((encoded[0] >> 7) & 0x10u);629bz |= ((encoded[0] >> 12) & 0x3u);630by |= ((encoded[0] >> 10) & 0x10u);631gw |= ((encoded[0] >> 15) & 0x3fu);632gy |= ((encoded[0] >> 16) & 0x20u);633by |= ((encoded[0] >> 17) & 0x20u);634bz |= ((encoded[0] >> 21) & 0x4u);635gy |= ((encoded[0] >> 20) & 0x10u);636bw |= ((encoded[0] >> 25) & 0x3fu);637gz |= ((encoded[0] >> 26) & 0x20u);638bz |= ((encoded[1] << 3) & 0x8u);639bz |= ((encoded[1] << 4) & 0x20u);640bz |= ((encoded[1] << 2) & 0x10u);641rx |= ((encoded[1] >> 3) & 0x3fu);642gy |= ((encoded[1] >> 9) & 0xfu);643gx |= ((encoded[1] >> 13) & 0x3fu);644gz |= ((encoded[1] >> 19) & 0xfu);645bx |= ((encoded[1] >> 23) & 0x3fu);646by |= ((encoded[1] >> 29) & 0x7u);647by |= ((encoded[2] << 3) & 0x8u);648ry |= ((encoded[2] >> 1) & 0x3fu);649rz |= ((encoded[2] >> 7) & 0x3fu);650d |= ((encoded[2] >> 13) & 0x1fu);651outD = d;652outRW = rw;653outRX = rx;654outRY = ry;655outRZ = rz;656outGW = gw;657outGX = gx;658outGY = gy;659outGZ = gz;660outBW = bw;661outBX = bx;662outBY = by;663outBZ = bz;664}665666void ReadMode10(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)667{668uint16_t d = 0;669uint16_t rw = 0;670uint16_t rx = 0;671uint16_t ry = 0;672uint16_t rz = 0;673uint16_t gw = 0;674uint16_t gx = 0;675uint16_t gy = 0;676uint16_t gz = 0;677uint16_t bw = 0;678uint16_t bx = 0;679uint16_t by = 0;680uint16_t bz = 0;681rw |= ((encoded[0] >> 5) & 0x3ffu);682gw |= ((encoded[0] >> 15) & 0x3ffu);683bw |= ((encoded[0] >> 25) & 0x7fu);684bw |= ((encoded[1] << 7) & 0x380u);685rx |= ((encoded[1] >> 3) & 0x3ffu);686gx |= ((encoded[1] >> 13) & 0x3ffu);687bx |= ((encoded[1] >> 23) & 0x1ffu);688bx |= ((encoded[2] << 9) & 0x200u);689outD = d;690outRW = rw;691outRX = rx;692outRY = ry;693outRZ = rz;694outGW = gw;695outGX = gx;696outGY = gy;697outGZ = gz;698outBW = bw;699outBX = bx;700outBY = by;701outBZ = bz;702}703704void ReadMode11(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)705{706uint16_t d = 0;707uint16_t rw = 0;708uint16_t rx = 0;709uint16_t ry = 0;710uint16_t rz = 0;711uint16_t gw = 0;712uint16_t gx = 0;713uint16_t gy = 0;714uint16_t gz = 0;715uint16_t bw = 0;716uint16_t bx = 0;717uint16_t by = 0;718uint16_t bz = 0;719rw |= ((encoded[0] >> 5) & 0x3ffu);720gw |= ((encoded[0] >> 15) & 0x3ffu);721bw |= ((encoded[0] >> 25) & 0x7fu);722bw |= ((encoded[1] << 7) & 0x380u);723rx |= ((encoded[1] >> 3) & 0x1ffu);724rw |= ((encoded[1] >> 2) & 0x400u);725gx |= ((encoded[1] >> 13) & 0x1ffu);726gw |= ((encoded[1] >> 12) & 0x400u);727bx |= ((encoded[1] >> 23) & 0x1ffu);728bw |= ((encoded[2] << 10) & 0x400u);729outD = d;730outRW = rw;731outRX = rx;732outRY = ry;733outRZ = rz;734outGW = gw;735outGX = gx;736outGY = gy;737outGZ = gz;738outBW = bw;739outBX = bx;740outBY = by;741outBZ = bz;742}743744void ReadMode12(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)745{746uint16_t d = 0;747uint16_t rw = 0;748uint16_t rx = 0;749uint16_t ry = 0;750uint16_t rz = 0;751uint16_t gw = 0;752uint16_t gx = 0;753uint16_t gy = 0;754uint16_t gz = 0;755uint16_t bw = 0;756uint16_t bx = 0;757uint16_t by = 0;758uint16_t bz = 0;759rw |= ((encoded[0] >> 5) & 0x3ffu);760gw |= ((encoded[0] >> 15) & 0x3ffu);761bw |= ((encoded[0] >> 25) & 0x7fu);762bw |= ((encoded[1] << 7) & 0x380u);763rx |= ((encoded[1] >> 3) & 0xffu);764rw |= (encoded[1] & 0x800u);765rw |= ((encoded[1] >> 2) & 0x400u);766gx |= ((encoded[1] >> 13) & 0xffu);767gw |= ((encoded[1] >> 10) & 0x800u);768gw |= ((encoded[1] >> 12) & 0x400u);769bx |= ((encoded[1] >> 23) & 0xffu);770bw |= ((encoded[1] >> 20) & 0x800u);771bw |= ((encoded[2] << 10) & 0x400u);772outD = d;773outRW = rw;774outRX = rx;775outRY = ry;776outRZ = rz;777outGW = gw;778outGX = gx;779outGY = gy;780outGZ = gz;781outBW = bw;782outBX = bx;783outBY = by;784outBZ = bz;785}786787void ReadMode13(const uint32_t *encoded, uint16_t &outD, uint16_t &outRW, uint16_t &outRX, uint16_t &outRY, uint16_t &outRZ, uint16_t &outGW, uint16_t &outGX, uint16_t &outGY, uint16_t &outGZ, uint16_t &outBW, uint16_t &outBX, uint16_t &outBY, uint16_t &outBZ)788{789uint16_t d = 0;790uint16_t rw = 0;791uint16_t rx = 0;792uint16_t ry = 0;793uint16_t rz = 0;794uint16_t gw = 0;795uint16_t gx = 0;796uint16_t gy = 0;797uint16_t gz = 0;798uint16_t bw = 0;799uint16_t bx = 0;800uint16_t by = 0;801uint16_t bz = 0;802rw |= ((encoded[0] >> 5) & 0x3ffu);803gw |= ((encoded[0] >> 15) & 0x3ffu);804bw |= ((encoded[0] >> 25) & 0x7fu);805bw |= ((encoded[1] << 7) & 0x380u);806rx |= ((encoded[1] >> 3) & 0xfu);807rw |= ((encoded[1] << 8) & 0x8000u);808rw |= ((encoded[1] << 6) & 0x4000u);809rw |= ((encoded[1] << 4) & 0x2000u);810rw |= ((encoded[1] << 2) & 0x1000u);811rw |= (encoded[1] & 0x800u);812rw |= ((encoded[1] >> 2) & 0x400u);813gx |= ((encoded[1] >> 13) & 0xfu);814gw |= ((encoded[1] >> 2) & 0x8000u);815gw |= ((encoded[1] >> 4) & 0x4000u);816gw |= ((encoded[1] >> 6) & 0x2000u);817gw |= ((encoded[1] >> 8) & 0x1000u);818gw |= ((encoded[1] >> 10) & 0x800u);819gw |= ((encoded[1] >> 12) & 0x400u);820bx |= ((encoded[1] >> 23) & 0xfu);821bw |= ((encoded[1] >> 12) & 0x8000u);822bw |= ((encoded[1] >> 14) & 0x4000u);823bw |= ((encoded[1] >> 16) & 0x2000u);824bw |= ((encoded[1] >> 18) & 0x1000u);825bw |= ((encoded[1] >> 20) & 0x800u);826bw |= ((encoded[2] << 10) & 0x400u);827outD = d;828outRW = rw;829outRX = rx;830outRY = ry;831outRZ = rz;832outGW = gw;833outGX = gx;834outGY = gy;835outGZ = gz;836outBW = bw;837outBX = bx;838outBY = by;839outBZ = bz;840}841842const ReadFunc_t g_readFuncs[14] =843{844ReadMode0,845ReadMode1,846ReadMode2,847ReadMode3,848ReadMode4,849ReadMode5,850ReadMode6,851ReadMode7,852ReadMode8,853ReadMode9,854ReadMode10,855ReadMode11,856ReadMode12,857ReadMode13858};859860const WriteFunc_t g_writeFuncs[14] =861{862WriteMode0,863WriteMode1,864WriteMode2,865WriteMode3,866WriteMode4,867WriteMode5,868WriteMode6,869WriteMode7,870WriteMode8,871WriteMode9,872WriteMode10,873WriteMode11,874WriteMode12,875WriteMode13876};877}878}879880#endif881882883