From df0c8e92d40a01c5909f6102054abc2d471a89c7 Mon Sep 17 00:00:00 2001 From: Andreas Haferburg Date: Mon, 14 Oct 2019 14:05:36 +0200 Subject: [PATCH 1/4] Fixed compiler warnings C4244 conversion from 'int' to 'unsigned char'/'unsigned short'. --- stb_dxt.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/stb_dxt.h b/stb_dxt.h index 6a76b1c..aa4df30 100644 --- a/stb_dxt.h +++ b/stb_dxt.h @@ -120,7 +120,7 @@ static void stb__From16Bit(unsigned char *out, unsigned short v) static unsigned short stb__As16Bit(int r, int g, int b) { - return (stb__Mul8Bit(r,31) << 11) + (stb__Mul8Bit(g,63) << 5) + stb__Mul8Bit(b,31); + return (unsigned short)((stb__Mul8Bit(r,31) << 11) + (stb__Mul8Bit(g,63) << 5) + stb__Mul8Bit(b,31)); } // linear interpolation at 1/3 point between a and b, using desired rounding type @@ -139,9 +139,9 @@ static int stb__Lerp13(int a, int b) // lerp RGB color static void stb__Lerp13RGB(unsigned char *out, unsigned char *p1, unsigned char *p2) { - out[0] = stb__Lerp13(p1[0], p2[0]); - out[1] = stb__Lerp13(p1[1], p2[1]); - out[2] = stb__Lerp13(p1[2], p2[2]); + out[0] = (unsigned char)stb__Lerp13(p1[0], p2[0]); + out[1] = (unsigned char)stb__Lerp13(p1[1], p2[1]); + out[2] = (unsigned char)stb__Lerp13(p1[2], p2[2]); } /****************************************************************************/ @@ -163,11 +163,11 @@ static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expan // +-1.5% error, but nowhere in the spec does it say that the error has to be // unbiased - better safe than sorry). err += STBD_ABS(maxe - mine) * 3 / 100; - + if(err < bestErr) - { - Table[i*2+0] = mx; - Table[i*2+1] = mn; + { + Table[i*2+0] = (unsigned char)mx; + Table[i*2+1] = (unsigned char)mn; bestErr = err; } } @@ -488,13 +488,13 @@ static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsign fg = frb * 63.0f / 31.0f; // solve. - max16 = stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11; - max16 |= stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5; - max16 |= stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0; + max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); + max16 |= (unsigned short)(stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5); + max16 |= (unsigned short)(stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0); - min16 = stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11; - min16 |= stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5; - min16 |= stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0; + min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); + min16 |= (unsigned short)(stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5); + min16 |= (unsigned short)(stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0); } *pmin16 = min16; @@ -592,8 +592,8 @@ static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src, int } // encode them - ((unsigned char *)dest)[0] = mx; - ((unsigned char *)dest)[1] = mn; + dest[0] = (unsigned char)mx; + dest[1] = (unsigned char)mn; dest += 2; // determine bias and emit color indices @@ -622,7 +622,7 @@ static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src, int // write index mask |= ind << bits; if((bits += 3) >= 8) { - *dest++ = mask; + *dest++ = (unsigned char)mask; mask >>= 8; bits -= 8; } @@ -633,10 +633,10 @@ static void stb__InitDXT() { int i; for(i=0;i<32;i++) - stb__Expand5[i] = (i<<3)|(i>>2); + stb__Expand5[i] = (unsigned char)((i<<3)|(i>>2)); for(i=0;i<64;i++) - stb__Expand6[i] = (i<<2)|(i>>4); + stb__Expand6[i] = (unsigned char)((i<<2)|(i>>4)); for(i=0;i<256+16;i++) { From 72646ac4aed8bbbe09e39d08029f5643b98eba5a Mon Sep 17 00:00:00 2001 From: Andreas Haferburg Date: Mon, 14 Oct 2019 14:16:11 +0200 Subject: [PATCH 2/4] Fixed whitespace --- stb_dxt.h | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/stb_dxt.h b/stb_dxt.h index aa4df30..eacad57 100644 --- a/stb_dxt.h +++ b/stb_dxt.h @@ -21,10 +21,10 @@ // v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom // v1.00 - (stb) first release // -// contributors: +// contributors: // Kevin Schmidt (#defines for "freestanding" compilation) // github:ppiastucki (BC4 support) -// +// // LICENSE // // See end of file for license information. @@ -66,7 +66,7 @@ STBDDEF void stb_compress_bc5_block(unsigned char *dest, const unsigned char *sr // STB_DXT_USE_ROUNDING_BIAS // use a rounding bias during color interpolation. this is closer to what "ideal" // interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03) -// implicitly had this turned on. +// implicitly had this turned on. // // in case you're targeting a specific type of hardware (e.g. console programmers): // NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer @@ -157,7 +157,7 @@ static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expan int mine = expand[mn]; int maxe = expand[mx]; int err = STBD_ABS(stb__Lerp13(maxe, mine) - i); - + // DX10 spec says that interpolation must be within 3% of "correct" result, // add this as error term. (normally we'd expect a random distribution of // +-1.5% error, but nowhere in the spec does it say that the error has to be @@ -236,7 +236,7 @@ static unsigned int stb__MatchColorsBlock(unsigned char *block, unsigned char *c // relying on this 1d approximation isn't always optimal in terms of euclidean distance, // but it's very close and a lot faster. // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html - + c0Point = (stops[1] + stops[3]) >> 1; halfPoint = (stops[3] + stops[2]) >> 1; c3Point = (stops[2] + stops[0]) >> 1; @@ -488,11 +488,11 @@ static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsign fg = frb * 63.0f / 31.0f; // solve. - max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); + max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); max16 |= (unsigned short)(stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5); max16 |= (unsigned short)(stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0); - min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); + min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); min16 |= (unsigned short)(stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5); min16 |= (unsigned short)(stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0); } @@ -511,7 +511,7 @@ static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, i int refinecount; unsigned short max16, min16; unsigned char dblock[16*4],color[4*4]; - + dither = mode & STB_DXT_DITHER; refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1; @@ -541,7 +541,7 @@ static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, i // third step: refine (multiple times if requested) for (i=0;i= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t; t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t; ind += (a >= dist); - + // turn linear scale into DXT index (0/1 are extremal pts) ind = -ind & 7; ind ^= (2 > ind); @@ -691,38 +691,38 @@ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ From c70479c47b60060cd9ea82470f1e0cd1637d696f Mon Sep 17 00:00:00 2001 From: Andreas Haferburg Date: Mon, 14 Oct 2019 14:23:36 +0200 Subject: [PATCH 3/4] Revert "Fixed whitespace" This reverts commit 72646ac4aed8bbbe09e39d08029f5643b98eba5a. --- stb_dxt.h | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/stb_dxt.h b/stb_dxt.h index eacad57..aa4df30 100644 --- a/stb_dxt.h +++ b/stb_dxt.h @@ -21,10 +21,10 @@ // v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom // v1.00 - (stb) first release // -// contributors: +// contributors: // Kevin Schmidt (#defines for "freestanding" compilation) // github:ppiastucki (BC4 support) -// +// // LICENSE // // See end of file for license information. @@ -66,7 +66,7 @@ STBDDEF void stb_compress_bc5_block(unsigned char *dest, const unsigned char *sr // STB_DXT_USE_ROUNDING_BIAS // use a rounding bias during color interpolation. this is closer to what "ideal" // interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03) -// implicitly had this turned on. +// implicitly had this turned on. // // in case you're targeting a specific type of hardware (e.g. console programmers): // NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer @@ -157,7 +157,7 @@ static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expan int mine = expand[mn]; int maxe = expand[mx]; int err = STBD_ABS(stb__Lerp13(maxe, mine) - i); - + // DX10 spec says that interpolation must be within 3% of "correct" result, // add this as error term. (normally we'd expect a random distribution of // +-1.5% error, but nowhere in the spec does it say that the error has to be @@ -236,7 +236,7 @@ static unsigned int stb__MatchColorsBlock(unsigned char *block, unsigned char *c // relying on this 1d approximation isn't always optimal in terms of euclidean distance, // but it's very close and a lot faster. // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html - + c0Point = (stops[1] + stops[3]) >> 1; halfPoint = (stops[3] + stops[2]) >> 1; c3Point = (stops[2] + stops[0]) >> 1; @@ -488,11 +488,11 @@ static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsign fg = frb * 63.0f / 31.0f; // solve. - max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); + max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); max16 |= (unsigned short)(stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5); max16 |= (unsigned short)(stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0); - min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); + min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); min16 |= (unsigned short)(stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5); min16 |= (unsigned short)(stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0); } @@ -511,7 +511,7 @@ static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, i int refinecount; unsigned short max16, min16; unsigned char dblock[16*4],color[4*4]; - + dither = mode & STB_DXT_DITHER; refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1; @@ -541,7 +541,7 @@ static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, i // third step: refine (multiple times if requested) for (i=0;i= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t; t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t; ind += (a >= dist); - + // turn linear scale into DXT index (0/1 are extremal pts) ind = -ind & 7; ind ^= (2 > ind); @@ -691,38 +691,38 @@ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ From 905d05a1d0b6583b35eeabf6886da5ff04cf380a Mon Sep 17 00:00:00 2001 From: Andreas Haferburg Date: Mon, 14 Oct 2019 14:24:47 +0200 Subject: [PATCH 4/4] Fixed whitespace --- stb_dxt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stb_dxt.h b/stb_dxt.h index aa4df30..96b8e58 100644 --- a/stb_dxt.h +++ b/stb_dxt.h @@ -488,11 +488,11 @@ static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsign fg = frb * 63.0f / 31.0f; // solve. - max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); + max16 = (unsigned short)(stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11); max16 |= (unsigned short)(stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5); max16 |= (unsigned short)(stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0); - min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); + min16 = (unsigned short)(stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11); min16 |= (unsigned short)(stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5); min16 |= (unsigned short)(stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0); }