46 GLuint pixerror, pixerrorred, pixerrorgreen, pixerrorblue, pixerrorbest;
47 GLint colordist, blockerrlin[2][3];
49 GLint pixerrorcolorbest[3];
56 if (((bestcolor[0][0] & 0xf8) << 8 | (bestcolor[0][1] & 0xfc) << 3 | bestcolor[0][2] >> 3) <
57 ((bestcolor[1][0] & 0xf8) << 8 | (bestcolor[1][1] & 0xfc) << 3 | bestcolor[1][2] >> 3)) {
58 testcolor[0][0] = bestcolor[0][0];
59 testcolor[0][1] = bestcolor[0][1];
60 testcolor[0][2] = bestcolor[0][2];
61 testcolor[1][0] = bestcolor[1][0];
62 testcolor[1][1] = bestcolor[1][1];
63 testcolor[1][2] = bestcolor[1][2];
66 testcolor[1][0] = bestcolor[0][0];
67 testcolor[1][1] = bestcolor[0][1];
68 testcolor[1][2] = bestcolor[0][2];
69 testcolor[0][0] = bestcolor[1][0];
70 testcolor[0][1] = bestcolor[1][1];
71 testcolor[0][2] = bestcolor[1][2];
74 for (
i = 0;
i < 3;
i ++) {
75 cv[0][
i] = testcolor[0][
i];
76 cv[1][
i] = testcolor[1][
i];
77 cv[2][
i] = (testcolor[0][
i] * 2 + testcolor[1][
i]) / 3;
78 cv[3][
i] = (testcolor[0][
i] + testcolor[1][
i] * 2) / 3;
81 blockerrlin[0][0] = 0;
82 blockerrlin[0][1] = 0;
83 blockerrlin[0][2] = 0;
84 blockerrlin[1][0] = 0;
85 blockerrlin[1][1] = 0;
86 blockerrlin[1][2] = 0;
91 for (
j = 0;
j < numypixels;
j++) {
92 for (
i = 0;
i < numxpixels;
i++) {
93 pixerrorbest = 0xffffffff;
94 for (colors = 0; colors < 4; colors++) {
95 colordist = srccolors[
j][
i][0] - (cv[colors][0]);
96 pixerror = colordist * colordist *
REDWEIGHT;
97 pixerrorred = colordist;
98 colordist = srccolors[
j][
i][1] - (cv[colors][1]);
100 pixerrorgreen = colordist;
101 colordist = srccolors[
j][
i][2] - (cv[colors][2]);
102 pixerror += colordist * colordist *
BLUEWEIGHT;
103 pixerrorblue = colordist;
104 if (pixerror < pixerrorbest) {
106 pixerrorbest = pixerror;
107 pixerrorcolorbest[0] = pixerrorred;
108 pixerrorcolorbest[1] = pixerrorgreen;
109 pixerrorcolorbest[2] = pixerrorblue;
113 for (
z = 0;
z < 3;
z++) {
114 blockerrlin[0][
z] += 3 * pixerrorcolorbest[
z];
119 for (
z = 0;
z < 3;
z++) {
120 blockerrlin[0][
z] += 2 * pixerrorcolorbest[
z];
123 for (
z = 0;
z < 3;
z++) {
124 blockerrlin[1][
z] += 1 * pixerrorcolorbest[
z];
129 for (
z = 0;
z < 3;
z++) {
130 blockerrlin[0][
z] += 1 * pixerrorcolorbest[
z];
133 for (
z = 0;
z < 3;
z++) {
134 blockerrlin[1][
z] += 2 * pixerrorcolorbest[
z];
139 for (
z = 0;
z < 3;
z++) {
140 blockerrlin[1][
z] += 3 * pixerrorcolorbest[
z];
146 if (nrcolor[0] == 0) nrcolor[0] = 1;
147 if (nrcolor[1] == 0) nrcolor[1] = 1;
148 for (
j = 0;
j < 2;
j++) {
149 for (
i = 0;
i < 3;
i++) {
150 GLint newvalue = testcolor[
j][
i] + blockerrlin[
j][
i] / nrcolor[
j];
153 else if (newvalue >= 255)
154 testcolor[
j][
i] = 255;
155 else testcolor[
j][
i] = newvalue;
159 if ((
abs(testcolor[0][0] - testcolor[1][0]) < 8) &&
160 (
abs(testcolor[0][1] - testcolor[1][1]) < 4) &&
161 (
abs(testcolor[0][2] - testcolor[1][2]) < 8)) {
163 GLubyte coldiffred, coldiffgreen, coldiffblue, coldiffmax,
factor, ind0, ind1;
165 coldiffred =
abs(testcolor[0][0] - testcolor[1][0]);
166 coldiffgreen = 2 *
abs(testcolor[0][1] - testcolor[1][1]);
167 coldiffblue =
abs(testcolor[0][2] - testcolor[1][2]);
168 coldiffmax = coldiffred;
169 if (coldiffmax < coldiffgreen) coldiffmax = coldiffgreen;
170 if (coldiffmax < coldiffblue) coldiffmax = coldiffblue;
171 if (coldiffmax > 0) {
172 if (coldiffmax > 4)
factor = 2;
173 else if (coldiffmax > 2)
factor = 3;
177 if (testcolor[1][1] >= testcolor[0][1]) {
183 if ((testcolor[ind1][1] +
factor * coldiffgreen) <= 255)
184 testcolor[ind1][1] +=
factor * coldiffgreen;
185 else testcolor[ind1][1] = 255;
186 if ((testcolor[ind1][0] - testcolor[ind0][1]) > 0) {
187 if ((testcolor[ind1][0] +
factor * coldiffred) <= 255)
188 testcolor[ind1][0] +=
factor * coldiffred;
189 else testcolor[ind1][0] = 255;
192 if ((testcolor[ind0][0] +
factor * coldiffred) <= 255)
193 testcolor[ind0][0] +=
factor * coldiffred;
194 else testcolor[ind0][0] = 255;
196 if ((testcolor[ind1][2] - testcolor[ind0][2]) > 0) {
197 if ((testcolor[ind1][2] +
factor * coldiffblue) <= 255)
198 testcolor[ind1][2] +=
factor * coldiffblue;
199 else testcolor[ind1][2] = 255;
202 if ((testcolor[ind0][2] +
factor * coldiffblue) <= 255)
203 testcolor[ind0][2] +=
factor * coldiffblue;
204 else testcolor[ind0][2] = 255;
209 if (((testcolor[0][0] & 0xf8) << 8 | (testcolor[0][1] & 0xfc) << 3 | testcolor[0][2] >> 3) <
210 ((testcolor[1][0] & 0xf8) << 8 | (testcolor[1][1] & 0xfc) << 3 | testcolor[1][2]) >> 3) {
211 for (
i = 0;
i < 3;
i++) {
212 bestcolor[0][
i] = testcolor[0][
i];
213 bestcolor[1][
i] = testcolor[1][
i];
217 for (
i = 0;
i < 3;
i++) {
218 bestcolor[0][
i] = testcolor[1][
i];
219 bestcolor[1][
i] = testcolor[0][
i];
235 GLuint testerror, testerror2, pixerror, pixerrorbest;
243 bestcolor[0][0] = bestcolor[0][0] & 0xf8;
244 bestcolor[0][1] = bestcolor[0][1] & 0xfc;
245 bestcolor[0][2] = bestcolor[0][2] & 0xf8;
246 bestcolor[1][0] = bestcolor[1][0] & 0xf8;
247 bestcolor[1][1] = bestcolor[1][1] & 0xfc;
248 bestcolor[1][2] = bestcolor[1][2] & 0xf8;
250 color0 = bestcolor[0][0] << 8 | bestcolor[0][1] << 3 | bestcolor[0][2] >> 3;
251 color1 = bestcolor[1][0] << 8 | bestcolor[1][1] << 3 | bestcolor[1][2] >> 3;
252 if (color0 < color1) {
253 tempcolor = color0; color0 = color1; color1 = tempcolor;
254 colorptr = bestcolor[0]; bestcolor[0] = bestcolor[1]; bestcolor[1] = colorptr;
258 for (
i = 0;
i < 3;
i++) {
259 cv[0][
i] = bestcolor[0][
i];
260 cv[1][
i] = bestcolor[1][
i];
261 cv[2][
i] = (bestcolor[0][
i] * 2 + bestcolor[1][
i]) / 3;
262 cv[3][
i] = (bestcolor[0][
i] + bestcolor[1][
i] * 2) / 3;
266 for (
j = 0;
j < numypixels;
j++) {
267 for (
i = 0;
i < numxpixels;
i++) {
268 pixerrorbest = 0xffffffff;
269 for (colors = 0; colors < 4; colors++) {
270 colordist = srccolors[
j][
i][0] - cv[colors][0];
271 pixerror = colordist * colordist *
REDWEIGHT;
272 colordist = srccolors[
j][
i][1] - cv[colors][1];
274 colordist = srccolors[
j][
i][2] - cv[colors][2];
275 pixerror += colordist * colordist *
BLUEWEIGHT;
276 if (pixerror < pixerrorbest) {
277 pixerrorbest = pixerror;
281 testerror += pixerrorbest;
282 bits |= enc << (2 * (
j * 4 +
i));
288 for (
i = 0;
i < 3;
i++) {
289 cv[2][
i] = (bestcolor[0][
i] + bestcolor[1][
i]) / 2;
297 for (
j = 0;
j < numypixels;
j++) {
298 for (
i = 0;
i < numxpixels;
i++) {
299 pixerrorbest = 0xffffffff;
306 for (colors = 0; colors < 3; colors++) {
307 colordist = srccolors[
j][
i][0] - cv[colors][0];
308 pixerror = colordist * colordist *
REDWEIGHT;
309 colordist = srccolors[
j][
i][1] - cv[colors][1];
311 colordist = srccolors[
j][
i][2] - cv[colors][2];
312 pixerror += colordist * colordist *
BLUEWEIGHT;
313 if (pixerror < pixerrorbest) {
314 pixerrorbest = pixerror;
316 if (colors > 1) enc = colors;
317 else enc = colors ^ 1;
321 testerror2 += pixerrorbest;
322 bits2 |= enc << (2 * (
j * 4 +
i));
326 testerror2 = 0xffffffff;
330 if ((testerror > testerror2) || (haveAlpha)) {
331 *blkaddr++ = color1 & 0xff;
332 *blkaddr++ = color1 >> 8;
333 *blkaddr++ = color0 & 0xff;
334 *blkaddr++ = color0 >> 8;
335 *blkaddr++ = bits2 & 0xff;
336 *blkaddr++ = ( bits2 >> 8) & 0xff;
337 *blkaddr++ = ( bits2 >> 16) & 0xff;
338 *blkaddr = bits2 >> 24;
341 *blkaddr++ = color0 & 0xff;
342 *blkaddr++ = color0 >> 8;
343 *blkaddr++ = color1 & 0xff;
344 *blkaddr++ = color1 >> 8;
345 *blkaddr++ =
bits & 0xff;
346 *blkaddr++ = (
bits >> 8) & 0xff;
347 *blkaddr++ = (
bits >> 16) & 0xff;
348 *blkaddr =
bits >> 24;
366 GLuint lowcv, highcv, testcv;
369 lowcv = highcv = srccolors[0][0][0] * srccolors[0][0][0] *
REDWEIGHT +
370 srccolors[0][0][1] * srccolors[0][0][1] *
GREENWEIGHT +
371 srccolors[0][0][2] * srccolors[0][0][2] *
BLUEWEIGHT;
372 bestcolor[0] = bestcolor[1] = srccolors[0][0];
373 for (
j = 0;
j < numypixels;
j++) {
374 for (
i = 0;
i < numxpixels;
i++) {
377 testcv = srccolors[
j][
i][0] * srccolors[
j][
i][0] *
REDWEIGHT +
380 if (testcv > highcv) {
382 bestcolor[1] = srccolors[
j][
i];
384 else if (testcv < lowcv) {
386 bestcolor[0] = srccolors[
j][
i];
393 for (
j = 0;
j < 2;
j++) {
394 for (
i = 0;
i < 3;
i++) {
395 basecolors[
j][
i] = bestcolor[
j][
i];
398 bestcolor[0] = basecolors[0];
399 bestcolor[1] = basecolors[1];
410 *blkaddr++ = alphabase1;
411 *blkaddr++ = alphabase2;
412 *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6);
413 *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7);
414 *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5);
415 *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6);
416 *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7);
417 *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5);
423 GLubyte alphabase[2], alphause[2];
425 GLuint alphablockerror1, alphablockerror2, alphablockerror3;
427 GLubyte alphaenc1[16], alphaenc2[16], alphaenc3[16];
433 alphabase[0] = 0xff; alphabase[1] = 0x0;
434 for (
j = 0;
j < numypixels;
j++) {
435 for (
i = 0;
i < numxpixels;
i++) {
436 if (srccolors[
j][
i][3] == 0)
438 else if (srccolors[
j][
i][3] == 255)
441 if (srccolors[
j][
i][3] > alphabase[1])
442 alphabase[1] = srccolors[
j][
i][3];
443 if (srccolors[
j][
i][3] < alphabase[0])
444 alphabase[0] = srccolors[
j][
i][3];
450 if ((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) {
455 *blkaddr++ = srccolors[0][0][3];
469 alphablockerror1 = 0x0;
470 alphablockerror2 = 0xffffffff;
471 alphablockerror3 = 0xffffffff;
472 if (alphaabsmin) alphause[0] = 0;
473 else alphause[0] = alphabase[0];
474 if (alphaabsmax) alphause[1] = 255;
475 else alphause[1] = alphabase[1];
477 for (aindex = 0; aindex < 7; aindex++) {
479 acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14;
482 for (
j = 0;
j < numypixels;
j++) {
483 for (
i = 0;
i < numxpixels;
i++) {
486 if (srccolors[
j][
i][3] > acutValues[0]) {
487 alphaenc1[4*
j +
i] = 0;
488 alphadist = srccolors[
j][
i][3] - alphause[1];
490 else if (srccolors[
j][
i][3] > acutValues[1]) {
491 alphaenc1[4*
j +
i] = 2;
492 alphadist = srccolors[
j][
i][3] - (alphause[1] * 6 + alphause[0] * 1) / 7;
494 else if (srccolors[
j][
i][3] > acutValues[2]) {
495 alphaenc1[4*
j +
i] = 3;
496 alphadist = srccolors[
j][
i][3] - (alphause[1] * 5 + alphause[0] * 2) / 7;
498 else if (srccolors[
j][
i][3] > acutValues[3]) {
499 alphaenc1[4*
j +
i] = 4;
500 alphadist = srccolors[
j][
i][3] - (alphause[1] * 4 + alphause[0] * 3) / 7;
502 else if (srccolors[
j][
i][3] > acutValues[4]) {
503 alphaenc1[4*
j +
i] = 5;
504 alphadist = srccolors[
j][
i][3] - (alphause[1] * 3 + alphause[0] * 4) / 7;
506 else if (srccolors[
j][
i][3] > acutValues[5]) {
507 alphaenc1[4*
j +
i] = 6;
508 alphadist = srccolors[
j][
i][3] - (alphause[1] * 2 + alphause[0] * 5) / 7;
510 else if (srccolors[
j][
i][3] > acutValues[6]) {
511 alphaenc1[4*
j +
i] = 7;
512 alphadist = srccolors[
j][
i][3] - (alphause[1] * 1 + alphause[0] * 6) / 7;
515 alphaenc1[4*
j +
i] = 1;
516 alphadist = srccolors[
j][
i][3] - alphause[0];
518 alphablockerror1 += alphadist * alphadist;
538 if (alphablockerror1 >= 32) {
542 alphablockerror2 = 0;
543 for (aindex = 0; aindex < 5; aindex++) {
545 acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10;
547 for (
j = 0;
j < numypixels;
j++) {
548 for (
i = 0;
i < numxpixels;
i++) {
551 if (srccolors[
j][
i][3] == 0) {
552 alphaenc2[4*
j +
i] = 6;
555 else if (srccolors[
j][
i][3] == 255) {
556 alphaenc2[4*
j +
i] = 7;
559 else if (srccolors[
j][
i][3] <= acutValues[0]) {
560 alphaenc2[4*
j +
i] = 0;
561 alphadist = srccolors[
j][
i][3] - alphabase[0];
563 else if (srccolors[
j][
i][3] <= acutValues[1]) {
564 alphaenc2[4*
j +
i] = 2;
565 alphadist = srccolors[
j][
i][3] - (alphabase[0] * 4 + alphabase[1] * 1) / 5;
567 else if (srccolors[
j][
i][3] <= acutValues[2]) {
568 alphaenc2[4*
j +
i] = 3;
569 alphadist = srccolors[
j][
i][3] - (alphabase[0] * 3 + alphabase[1] * 2) / 5;
571 else if (srccolors[
j][
i][3] <= acutValues[3]) {
572 alphaenc2[4*
j +
i] = 4;
573 alphadist = srccolors[
j][
i][3] - (alphabase[0] * 2 + alphabase[1] * 3) / 5;
575 else if (srccolors[
j][
i][3] <= acutValues[4]) {
576 alphaenc2[4*
j +
i] = 5;
577 alphadist = srccolors[
j][
i][3] - (alphabase[0] * 1 + alphabase[1] * 4) / 5;
580 alphaenc2[4*
j +
i] = 1;
581 alphadist = srccolors[
j][
i][3] - alphabase[1];
583 alphablockerror2 += alphadist * alphadist;
590 if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) {
594 GLubyte nralphainrangehigh = 0;
598 for (
j = 0;
j < numypixels;
j++) {
599 for (
i = 0;
i < numxpixels;
i++) {
600 if ((srccolors[
j][
i][3] > alphatest[1]) && (srccolors[
j][
i][3] < (255 -(alphabase[1] - alphabase[0]) / 28)))
601 alphatest[1] = srccolors[
j][
i][3];
602 if ((srccolors[
j][
i][3] < alphatest[0]) && (srccolors[
j][
i][3] > (alphabase[1] - alphabase[0]) / 28))
603 alphatest[0] = srccolors[
j][
i][3];
607 if (alphatest[1] <= alphatest[0]) {
612 for (aindex = 0; aindex < 5; aindex++) {
614 acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10;
624 for (
j = 0;
j < numypixels;
j++) {
625 for (
i = 0;
i < numxpixels;
i++) {
626 if (srccolors[
j][
i][3] <= alphatest[0] / 2) {
628 else if (srccolors[
j][
i][3] > ((255 + alphatest[1]) / 2)) {
630 else if (srccolors[
j][
i][3] <= acutValues[0]) {
631 blockerrlin1 += (srccolors[
j][
i][3] - alphatest[0]);
632 nralphainrangelow += 1;
634 else if (srccolors[
j][
i][3] <= acutValues[1]) {
635 blockerrlin1 += (srccolors[
j][
i][3] - (alphatest[0] * 4 + alphatest[1] * 1) / 5);
636 blockerrlin2 += (srccolors[
j][
i][3] - (alphatest[0] * 4 + alphatest[1] * 1) / 5);
637 nralphainrangelow += 1;
638 nralphainrangehigh += 1;
640 else if (srccolors[
j][
i][3] <= acutValues[2]) {
641 blockerrlin1 += (srccolors[
j][
i][3] - (alphatest[0] * 3 + alphatest[1] * 2) / 5);
642 blockerrlin2 += (srccolors[
j][
i][3] - (alphatest[0] * 3 + alphatest[1] * 2) / 5);
643 nralphainrangelow += 1;
644 nralphainrangehigh += 1;
646 else if (srccolors[
j][
i][3] <= acutValues[3]) {
647 blockerrlin1 += (srccolors[
j][
i][3] - (alphatest[0] * 2 + alphatest[1] * 3) / 5);
648 blockerrlin2 += (srccolors[
j][
i][3] - (alphatest[0] * 2 + alphatest[1] * 3) / 5);
649 nralphainrangelow += 1;
650 nralphainrangehigh += 1;
652 else if (srccolors[
j][
i][3] <= acutValues[4]) {
653 blockerrlin1 += (srccolors[
j][
i][3] - (alphatest[0] * 1 + alphatest[1] * 4) / 5);
654 blockerrlin2 += (srccolors[
j][
i][3] - (alphatest[0] * 1 + alphatest[1] * 4) / 5);
655 nralphainrangelow += 1;
656 nralphainrangehigh += 1;
659 blockerrlin2 += (srccolors[
j][
i][3] - alphatest[1]);
660 nralphainrangehigh += 1;
665 if (nralphainrangelow == 0) nralphainrangelow = 1;
666 if (nralphainrangehigh == 0) nralphainrangehigh = 1;
667 alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow);
671 if (alphatest[0] < 0) {
675 alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh);
676 if (alphatest[1] > 255) {
681 alphablockerror3 = 0;
682 for (aindex = 0; aindex < 5; aindex++) {
684 acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10;
686 for (
j = 0;
j < numypixels;
j++) {
687 for (
i = 0;
i < numxpixels;
i++) {
690 if (srccolors[
j][
i][3] <= alphatest[0] / 2) {
691 alphaenc3[4*
j +
i] = 6;
692 alphadist = srccolors[
j][
i][3];
694 else if (srccolors[
j][
i][3] > ((255 + alphatest[1]) / 2)) {
695 alphaenc3[4*
j +
i] = 7;
696 alphadist = 255 - srccolors[
j][
i][3];
698 else if (srccolors[
j][
i][3] <= acutValues[0]) {
699 alphaenc3[4*
j +
i] = 0;
700 alphadist = srccolors[
j][
i][3] - alphatest[0];
702 else if (srccolors[
j][
i][3] <= acutValues[1]) {
703 alphaenc3[4*
j +
i] = 2;
704 alphadist = srccolors[
j][
i][3] - (alphatest[0] * 4 + alphatest[1] * 1) / 5;
706 else if (srccolors[
j][
i][3] <= acutValues[2]) {
707 alphaenc3[4*
j +
i] = 3;
708 alphadist = srccolors[
j][
i][3] - (alphatest[0] * 3 + alphatest[1] * 2) / 5;
710 else if (srccolors[
j][
i][3] <= acutValues[3]) {
711 alphaenc3[4*
j +
i] = 4;
712 alphadist = srccolors[
j][
i][3] - (alphatest[0] * 2 + alphatest[1] * 3) / 5;
714 else if (srccolors[
j][
i][3] <= acutValues[4]) {
715 alphaenc3[4*
j +
i] = 5;
716 alphadist = srccolors[
j][
i][3] - (alphatest[0] * 1 + alphatest[1] * 4) / 5;
719 alphaenc3[4*
j +
i] = 1;
720 alphadist = srccolors[
j][
i][3] - alphatest[1];
722 alphablockerror3 += alphadist * alphadist;
728 if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) {
732 else if (alphablockerror2 <= alphablockerror3) {
747 for (
j = 0;
j < numypixels;
j++) {
748 curaddr = srcaddr +
j * srcRowStride * comps;
749 for (
i = 0;
i < numxpixels;
i++) {
750 for (
c = 0;
c < comps;
c++) {
751 srcpixels[
j][
i][
c] = *curaddr++ / (
CHAN_MAX / 255);
763 const GLchan *srcaddr = srcPixData;
764 GLint numxpixels, numypixels;
768 switch (destFormat) {
772 dstRowDiff = dstRowStride >= (
width * 2) ? dstRowStride - (((
width + 3) & ~3) * 2) : 0;
776 if (
height >
j + 3) numypixels = 4;
778 srcaddr = srcPixData +
j *
width * srccomps;
780 if (
width >
i + 3) numxpixels = 4;
781 else numxpixels =
width -
i;
784 srcaddr += srccomps * numxpixels;
787 blkaddr += dstRowDiff;
791 dstRowDiff = dstRowStride >= (
width * 4) ? dstRowStride - (((
width + 3) & ~3) * 4) : 0;
795 if (
height >
j + 3) numypixels = 4;
797 srcaddr = srcPixData +
j *
width * srccomps;
799 if (
width >
i + 3) numxpixels = 4;
800 else numxpixels =
width -
i;
802 *blkaddr++ = (srcpixels[0][0][3] >> 4) | (srcpixels[0][1][3] & 0xf0);
803 *blkaddr++ = (srcpixels[0][2][3] >> 4) | (srcpixels[0][3][3] & 0xf0);
804 *blkaddr++ = (srcpixels[1][0][3] >> 4) | (srcpixels[1][1][3] & 0xf0);
805 *blkaddr++ = (srcpixels[1][2][3] >> 4) | (srcpixels[1][3][3] & 0xf0);
806 *blkaddr++ = (srcpixels[2][0][3] >> 4) | (srcpixels[2][1][3] & 0xf0);
807 *blkaddr++ = (srcpixels[2][2][3] >> 4) | (srcpixels[2][3][3] & 0xf0);
808 *blkaddr++ = (srcpixels[3][0][3] >> 4) | (srcpixels[3][1][3] & 0xf0);
809 *blkaddr++ = (srcpixels[3][2][3] >> 4) | (srcpixels[3][3][3] & 0xf0);
811 srcaddr += srccomps * numxpixels;
814 blkaddr += dstRowDiff;
818 dstRowDiff = dstRowStride >= (
width * 4) ? dstRowStride - (((
width + 3) & ~3) * 4) : 0;
822 if (
height >
j + 3) numypixels = 4;
824 srcaddr = srcPixData +
j *
width * srccomps;
826 if (
width >
i + 3) numxpixels = 4;
827 else numxpixels =
width -
i;
831 srcaddr += srccomps * numxpixels;
834 blkaddr += dstRowDiff;
838 fprintf(
stderr,
"libdxtn: Bad dstFormat %d in tx_compress_dxtn\n", destFormat);
void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData, GLenum destFormat, GLubyte *dest, GLint dstRowStride)
static void encodedxtcolorblockfaster(GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLint numxpixels, GLint numypixels, GLuint type)
static void writedxt5encodedalphablock(GLubyte *blkaddr, GLubyte alphabase1, GLubyte alphabase2, GLubyte alphaenc[16])
static void encodedxt5alpha(GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLint numxpixels, GLint numypixels)
static void storedxtencodedblock(GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLubyte *bestcolor[2], GLint numxpixels, GLint numypixels, GLuint type, GLboolean haveAlpha)
static void extractsrccolors(GLubyte srcpixels[4][4][4], const GLchan *srcaddr, GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps)
static void fancybasecolorsearch(GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLubyte *bestcolor[2], GLint numxpixels, GLint numypixels, GLint type, GLboolean haveAlpha)
GLuint GLuint GLsizei GLenum type
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint factor
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)