Skip to content
Myr

Integrate more accurate index selection by Rich Geldreich.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ignacio Castano · committed by Ignacio Castano · parent f54acd4 · Browse files · 1 file+8 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−7 removed

  • other:+8 added−7 removed

1 file+8 added−7 removed

modified:stb_dxt.h+8 added-7 removed
22 unmodified lines
23// v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom24// v1.00 - (stb) first release25//26// contributors:27// Rich Geldreich (more accurate index selection)28// Kevin Schmidt (#defines for "freestanding" compilation)29// github:ppiastucki (BC4 support)30//31// LICENSE
207 unmodified lines
239 // relying on this 1d approximation isn't always optimal in terms of euclidean distance,240 // but it's very close and a lot faster.241 // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html242242 c0Point = (stops[1] + stops[3]) >> 1;243 halfPoint = (stops[3] + stops[2]) >> 1;244 c3Point = (stops[2] + stops[0]) >> 1;243 c0Point = (stops[1] + stops[3]);244 halfPoint = (stops[3] + stops[2]);245 c3Point = (stops[2] + stops[0]);246247 if(!dither) {248 // the version without dithering is straightforward249 for (i=15;i>=0;i--) {249 int dot = dots[i];250 int dot = dots[i]*2;251 mask <<= 2;252253 if(dot < halfPoint)254 mask |= (dot < c0Point) ? 1 : 3;
4 unmodified lines
259 // with floyd-steinberg dithering260 int err[8],*ep1 = err,*ep2 = err+4;261 int *dp = dots, y;262262 c0Point <<= 4;263 halfPoint <<= 4;264 c3Point <<= 4;263 c0Point <<= 3;264 halfPoint <<= 3;265 c3Point <<= 3;266 for(i=0;i<8;i++)267 err[i] = 0;268269 for(y=0;y<4;y++)
462 unmodified lines