From 9b3358fec13d0847886672e4ccd6e6aa6408a229 Mon Sep 17 00:00:00 2001 From: Kevin Schmidt Date: Tue, 18 Apr 2017 18:28:02 +0200 Subject: [PATCH 1/2] Add feature to replace abs/fabs and memset with your own. --- stb_dxt.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/stb_dxt.h b/stb_dxt.h index 5399799..95320d0 100644 --- a/stb_dxt.h +++ b/stb_dxt.h @@ -61,8 +61,23 @@ void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two // #define STB_DXT_USE_ROUNDING_BIAS #include + +#if !defined(STBD_ABS) || !defined(STBI_FABS) #include -#include // memset +#endif + +#ifndef STBD_ABS +#define STBD_ABS(i) abs(i) +#endif + +#ifndef STBD_FABS +#define STBD_FABS(x) fabs(x) +#endif + +#ifndef STBD_MEMSET +#include +#define STBD_MEMSET(x) memset(x) +#endif static unsigned char stb__Expand5[32]; static unsigned char stb__Expand6[64]; @@ -127,13 +142,13 @@ static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expan for (mx=0;mx> 4)]; ep1[0] = bp[ 0] - dp[ 0]; @@ -349,9 +364,9 @@ static void stb__OptimizeColorsBlock(unsigned char *block, unsigned short *pmax1 vfb = b; } - magn = fabs(vfr); - if (fabs(vfg) > magn) magn = fabs(vfg); - if (fabs(vfb) > magn) magn = fabs(vfb); + magn = STBD_FABS(vfr); + if (STBD_FABS(vfg) > magn) magn = STBD_FABS(vfg); + if (STBD_FABS(vfb) > magn) magn = STBD_FABS(vfb); if(magn < 4.0f) { // too small, default to luminance v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000. From 50e6be0de6a2211f7ec6d6d82eacb34e583fd1c0 Mon Sep 17 00:00:00 2001 From: Kevin Schmidt Date: Tue, 18 Apr 2017 18:31:15 +0200 Subject: [PATCH 2/2] Edit contributor list. --- stb_dxt.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stb_dxt.h b/stb_dxt.h index 95320d0..3ff25bc 100644 --- a/stb_dxt.h +++ b/stb_dxt.h @@ -19,6 +19,9 @@ // v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom // v1.00 - (stb) first release // +// contributors: +// Kevin Schmidt +// // LICENSE // // See end of file for license information.