MCPcopy Create free account
hub / github.com/DentonW/DevIL / inxsearch

Function inxsearch

DevIL/src-IL/src/il_neuquant.cpp:191–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189// ----------------------------------------------------------------------------
190
191ILubyte inxsearch(ILint b, ILint g, ILint r)
192{
193 ILint i,j,dist,a,bestd;
194 ILint *p;
195 ILint best;
196
197 bestd = 1000; // biggest possible dist is 256*3
198 best = -1;
199 i = netindex[g]; // index on g
200 j = i-1; // start at netindex[g] and work outwards
201
202 while ((i<netsizethink) || (j>=0)) {
203 if (i<netsizethink) {
204 p = network[i];
205 dist = p[1] - g; // inx key
206 if (dist >= bestd) i = netsizethink; // stop iter
207 else {
208 i++;
209 if (dist<0) dist = -dist;
210 a = p[0] - b; if (a<0) a = -a;
211 dist += a;
212 if (dist<bestd) {
213 a = p[2] - r; if (a<0) a = -a;
214 dist += a;
215 if (dist<bestd) {bestd=dist; best=p[3];}
216 }
217 }
218 }
219 if (j>=0) {
220 p = network[j];
221 dist = g - p[1]; // inx key - reverse dif
222 if (dist >= bestd) j = -1; // stop iter
223 else {
224 j--;
225 if (dist<0) dist = -dist;
226 a = p[0] - b; if (a<0) a = -a;
227 dist += a;
228 if (dist<bestd) {
229 a = p[2] - r; if (a<0) a = -a;
230 dist += a;
231 if (dist<bestd) {bestd=dist; best=p[3];}
232 }
233 }
234 }
235 }
236 return (ILubyte)best;
237}
238
239
240// Search for biased BGR values

Callers 1

iNeuQuantFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected