28 #include "../../../idlib/precompiled.h"
35 if (val>255)
return 255;
45 for(i=0; i < 256; i++) {
49 for(i=0; i < 256; i++) {
83 void codec::Sort(
float *list,
int *intIndex,
int numElements )
85 #define STRIDE_FACTOR 3 // good value for stride factor is not well-understood
91 while (stride <= numElements)
94 while (stride>(STRIDE_FACTOR-1)) {
97 for (c = stride; c < numElements; c++){
100 while ((d >= 0) && !found) {
101 if (list[d]<list[d+stride]) {
104 ftemp = list[d]; list[d] = list[d+
stride]; list[d+
stride] = ftemp;
105 itemp = intIndex[d]; intIndex[d] = intIndex[d+
stride]; intIndex[d+
stride] = itemp;
116 int x,
y, yy, xx, numc, onf,
index, temp, best, a0, a1, a2, a3, bpp,
i,
len;
120 char cbFile[256], tempcb[256], temptb[256];
122 float y0,
y1,
y2,y3,cr,cb;
125 a0 = a1 = a2 = a3 = 0;
131 len = (
int)strlen(tempcb);
133 if (tempcb[x] ==
'\n')
for(y=x;y<
len;y++)
if (tempcb[y] ==
'/') x = y+1;
134 cbFile[onf++] = tempcb[
x];
146 if (
dimension2 == 16 ) x = 3584;
else x = 2560;
147 if ( fpcb->
Read( lineout, x ) !=
x ) {
157 if (numElements > numc) numc = numElements;
165 bpp =
image->samplesPerPixel();
175 snrBook[numEntries] = 1.0f;
180 for(yy=y;yy<(y+4);yy++) {
181 for(xx=x;xx<(x+4);xx++) {
182 src =
image->bitmapData() + (yy*(bpp*
image->pixelsWide())) + (xx*bpp);
183 memcpy( dst, src, 3); dst += 3;
190 common->
Printf(
"segment: %d 4x4 cels to vq\n", numEntries );
197 for( i=0; i<256; i++ ) {
200 snrBook[numEntries] = 1.0f;
202 for(yy=y;yy<(y+2);yy++) {
203 for(xx=x;xx<(x+2);xx++) {
213 common->
Printf(
"segment: %d 2x2 cels to vq\n", numEntries);
221 for( onf = 0; onf < 256; onf++ ) {
222 numc = 0; fcr = fcb = 0;
223 for( x = 0; x < 4; x++ ) {
227 if (fy<0) fy = 0;
if (fy>255) fy = 255;
237 lineout[index++] = (
byte)fy;
240 fcr = (fcr/4)+128.5
f;
if (fcr<0) fcr = 0;
if (fcr>255) fcr = 255;
241 fcb = (fcb/4)+128.5
f;
if (fcb<0) fcb = 0;
if (fcb>255) fcr = 255;
243 lineout[index++] = (
byte)fcr;
244 lineout[index++] = (
byte)fcb;
247 for(onf=0;onf<256;onf++) {
251 for(yy=y;yy<(y+2);yy++) {
267 fpcb->
Write( lineout, index );
274 y0 = (
float)lineout[x++];
275 y1 = (
float)lineout[x++];
276 y2 = (
float)lineout[x++];
277 y3 = (
float)lineout[x++];
278 cb = (
float)lineout[x++]; cb -= 128;
279 cr = (
float)lineout[x ]; cr -= 128;
297 for(onf=0;onf<256;onf++) {
300 best = lineout[index++];
302 for(yy=y;yy<(y+2);yy++) {
328 for(
int i=0;
i<dimension;
i++ ) {
329 tempvq[
i] = tempvector[
i];
332 for(
int i=0;
i<256;
i++) {
334 for(
int x=0;
x<dimension;
x+=3 ) {
341 dist += (r0-r1)*(r0-r1);
342 if (dist >= bestDist) {
345 dist += (g0-g1)*(g0-g1);
346 if (dist >= bestDist) {
349 dist += (b0-b1)*(b0-b1);
350 if (dist >= bestDist) {
354 if ( dist < bestDist ) {
387 int i, dy, dx, pluck,
size, ind, xx, yy, pWide;
389 byte *rgbmap, *idataA, *fccdictionary;
412 size = pquad[
i].
size;
414 switch( pquad[i].status ) {
420 for( dy=0; dy<
size; dy++ ) {
421 pluck = (((dy+pquad[
i].
yat)*pWide)+pquad[
i].
xat)*4;
422 for( dx=0; dx<
size; dx++ ) {
424 if (rgbmap[pluck+0] !=
codebook4[ind][xx+0]) diff =
true;
425 if (rgbmap[pluck+1] !=
codebook4[ind][xx+1]) diff =
true;
426 if (rgbmap[pluck+2] !=
codebook4[ind][xx+2]) diff =
true;
435 rgbmap[pluck+3] = 255;
444 for( dy=0; dy<
size; dy++ ) {
445 pluck = (((dy+pquad[
i].
yat)*pWide)+pquad[
i].
xat)*4;
446 for( dx=0; dx<
size; dx++ ) {
448 if (rgbmap[pluck+0] !=
codebook4[ind][xx+0]) diff =
true;
449 if (rgbmap[pluck+1] !=
codebook4[ind][xx+1]) diff =
true;
450 if (rgbmap[pluck+2] !=
codebook4[ind][xx+2]) diff =
true;
459 rgbmap[pluck+3] = 255;
467 for(yy=0;yy<4;yy+=2) {
468 for(xx=0;xx<4;xx+=2) {
472 for(y=yy;y<(yy+2);y++) {
473 for(x=xx;x<(xx+2);x++) {
474 pluck = (((y+pquad[
i].
yat)*pWide)+(pquad[
i].
xat+
x))*4;
475 if (rgbmap[pluck+0] !=
codebook2[ind][dy+0]) diff =
true;
476 if (rgbmap[pluck+1] !=
codebook2[ind][dy+1]) diff =
true;
477 if (rgbmap[pluck+2] !=
codebook2[ind][dy+2]) diff =
true;
487 rgbmap[pluck+3] = 255;
514 dx = pquad[
i].
xat - ((pquad[
i].
domain >> 8 ) - 128);
515 dy = pquad[
i].
yat - ((pquad[
i].
domain & 0xff) - 128);
516 if (
image->pixelsWide()==(
image->pixelsHigh()*4)) dx = pquad[
i].
xat - ((pquad[
i].
domain >> 8 ) - 128)*2;
518 dx = pquad[
i].
xat - ((pquad[
i].
domain >> 8 ) - 128)*2;
519 dy = pquad[
i].
yat - ((pquad[
i].
domain & 0xff) - 128)*2;
523 ind = (dy*pWide+dx)*4;
524 for( dy=0; dy<
size; dy++ ) {
525 pluck = (((dy+pquad[
i].
yat)*pWide)+pquad[
i].
xat)*4;
526 for( dx=0; dx<
size; dx++ ) {
527 if (rgbmap[pluck+0] != fccdictionary[ind+0]) diff =
true;
528 if (rgbmap[pluck+1] != fccdictionary[ind+1]) diff =
true;
529 if (rgbmap[pluck+2] != fccdictionary[ind+2]) diff =
true;
531 rgbmap[pluck+0] = fccdictionary[ind+0];
532 rgbmap[pluck+1] = fccdictionary[ind+1];
533 rgbmap[pluck+2] = fccdictionary[ind+2];
534 rgbmap[pluck+3] = fccdictionary[ind+3];
535 pluck += 4; ind += 4;
537 ind += (pWide -
size)*4;
566 int x,
y, index0, index1, temp;
584 common->
Printf(
"initImage: remaking lut image using buffer %d\n", temp);
589 ftemp =
RMULT*lutimage[index0+0] +
GMULT*lutimage[index0+1] +
BMULT*lutimage[index0+2];
604 int bigx, bigy, lowx, lowy;
610 if ( (startX >= lowx) && (startX+quadSize) <= (bigx) && (startY+quadSize) <= (bigy) && (startY >= lowy) && quadSize <=
MAXSIZE) {
619 startSize = quadSize>>1;
620 QuadX( startX , startY , startSize );
621 QuadX( startX+startSize , startY , startSize );
622 QuadX( startX , startY+startSize , startSize );
623 QuadX( startX+startSize , startY+startSize , startSize );
645 byte tempImage[8*8*4];
646 int x,
y,
i, best, temp;
652 tempImage[i++] = (cel[temp+0]+cel[temp+4]+cel[temp+32]+cel[temp+36])/4;
653 tempImage[i++] = (cel[temp+1]+cel[temp+5]+cel[temp+33]+cel[temp+37])/4;
654 tempImage[i++] = (cel[temp+2]+cel[temp+6]+cel[temp+34]+cel[temp+38])/4;
656 tempImage[i++] = (cel[temp+3]+cel[temp+7]+cel[temp+35]+cel[temp+39])/4;
672 tempImage[temp+3] = 255;
676 pquad->
snr[
SLD] =
Snr( cel, tempImage, 8 )+1.0;
687 tempImage[i*bpp+0] = cel[i*4+0];
688 tempImage[i*bpp+1] = cel[i*4+1];
689 tempImage[i*bpp+2] = cel[i*4+2];
690 if (
dimension4 == 64) tempImage[i*bpp+3] = cel[i*4+3];
702 tempImage[i*4+3] = 255;
705 pquad->
snr[
PAT] =
Snr( cel, tempImage, 4 );
710 byte tempImage[16], tempOut[64];
711 int i,
j, best,
x,
y,xx,yy,bpp;
715 for(yy=0;yy<4;yy+=2) {
716 for(xx=0;xx<4;xx+=2) {
718 for(y=yy;y<(yy+2);y++) {
719 for(x=xx;x<(xx+2);x++) {
720 tempImage[i++] = cel[y*16+x*4+0];
721 tempImage[i++] = cel[y*16+x*4+1];
722 tempImage[i++] = cel[y*16+x*4+2];
723 if (
dimension4 == 64) tempImage[i++] = cel[y*16+x*4+3];
728 for(y=yy;y<(yy+2);y++) {
729 for(x=xx;x<(xx+2);x++) {
736 tempOut[y*16+x*4+3] = 255;
742 pquad->
snr[
CCC] =
Snr( cel, tempOut, 4 );
757 for(i=0; i<
size; i++) {
758 for(j=0; j<
size; j++) {
759 if (old[3]||bnew[3]) ind +=
RGBADIST( old, bnew );
766 fsnr = (
float)sqrt( fsnr );
778 for(i=0; i<
size; i++) {
779 for(j=0; j<
size; j++) {
790 int x,
y, xLen, yLen, mblur0, ripl, bpp, fabort, temp1;
791 int lowX, lowY, onx, ony, sX, sY, depthx, depthy, breakHigh;
792 float lowestSNR, fmblur0;
795 int searchY, searchX, xxMean, yyMean;
801 for(x=0; x<(size*
size); x++) {
802 fmblur0 =
RMULT*bitmap[x*4+0] +
GMULT*bitmap[x*4+1] +
BMULT*bitmap[x*4+2];
811 ony = realy - (realy & 0xfff0);
812 onx = realx - (realx & 0xfff0);
818 breakHigh = 99999999;
828 if (clamp) { searchX = searchY = 8; }
829 searchX = searchX*depthx;
830 searchY = searchY*depthy;
834 if (((realx-xxMean)+searchX)<0 ||(((realx-xxMean)-searchX)+depthx+size)>xLen || ((realy-yyMean)+searchY)<0 || (((realy-yyMean)-searchY)+depthy+size)>yLen) {
840 for( sX=(((realx-xxMean)-searchX)+depthx); sX<=((realx-xxMean)+searchX) && !fabort; sX+=depthx ) {
841 for( sY=(((realy-yyMean)-searchY)+depthy); sY<=((realy-yyMean)+searchY) && breakHigh; sY+=depthy ) {
843 if ( sX >= 0 && (sX+size) <= xLen && sY >= 0 && (sY+
size) <= yLen ) {
845 ripl = (xLen-
size)*bpp;
852 for( y=0; y<
size; y++) {
853 for( x=0; x<
size; x++) {
854 mblur0 +=
RGBADIST( bitma2, scale1);
855 bitma2 += 4; scale1 += 4;
857 if (mblur0 > breakHigh) {
862 if (breakHigh > mblur0) {
871 if (lowX != -1 && lowY != -1) {
873 ripl = (xLen-
size)*bpp;
877 for( y=0; y<
size; y++) {
878 for( x=0; x<
size; x++) {
879 mblur0 +=
RGBADIST( bitma2, scale1 );
880 scale1 += 4; bitma2 += 4;
886 lowestSNR = (
float)mblur0;
887 lowestSNR /= (size*
size);
888 lowestSNR = (
float)sqrt( lowestSNR );
890 sX = (realx-lowX+128);
891 sY = (realy-lowY+128);
894 sX = ((realx-lowX)/2+128);
897 sY = ((realy-lowY)/2+128);
899 pquad->
domain = (sX<<8)+sY;
900 pquad->
snr[
FCC] = lowestSNR;
907 int x,
y,yoff,bpp,yend,xend;
923 for(y=startY;y<yend;y++) {
925 for(x=startX;x<xend;x++) {
926 r = iPlane[0][yoff+(x*bpp)+0];
927 g = iPlane[0][yoff+(x*bpp)+1];
928 b = iPlane[0][yoff+(x*bpp)+2];
929 a = iPlane[0][yoff+(x*bpp)+3];
930 *iData++ =
r; *iData++ =
g; *iData++ =
b; *iData++ =
a;
935 for(y=startY;y<yend;y++) {
937 for(x=startX;x<xend;x++) {
938 r = iPlane[0][yoff+(x*bpp)+0];
939 g = iPlane[0][yoff+(x*bpp)+1];
940 b = iPlane[0][yoff+(x*bpp)+2];
941 *iData++ =
r; *iData++ =
g; *iData++ =
b;
951 float quickadd[
DEAD];
967 for(i=(
DEAD-1);i>0;i--) {
968 if ( qtemp->
snr[i]*quickadd[i] < wtemp ) {
970 *snr = qtemp->
snr[
i];
971 wtemp = qtemp->
snr[
i]*quickadd[
i];
975 if ( qtemp->
mark ) *status =
MOT;
980 int totalbits,
i, totalbytes;
981 int quickadd[
DEAD+1];
994 if (pquad[i].
size && pquad[i].
size < 16 ) totalbits += quickadd[pquad[
i].
status];
997 totalbytes = (totalbits >> 3)+2;
1009 if (pquad[i].
size && pquad[i].status && pquad[i].status !=
DEAD) {
1010 if (pquad[i].
size == 8) { totalbits += pquad[
i].
rsnr*4; j += 4; }
1011 if (pquad[i].
size == 4) { totalbits += pquad[
i].
rsnr*1; j += 1; }
1015 return ((
float)totalbits);
1022 byte *idataA, *idataB;
1026 if (pquad[lownum].
size == 8) {
1027 nx = 1; nsize = 4; cmul = 1;
1029 nx = 5; nsize = 8; cmul = 4;
1034 for( i=lownum+1; i<lownum+(nx*4)+1; i+=
nx ) {
1035 pquad[
i].
size = nsize;
1040 FvqData( idataA, pquad[i].size, pquad[i].xat, pquad[i].yat, &pquad[i],
true );
1042 pquad[
i].
snr[
MOT] =
Snr( idataA, idataB, pquad[i].size );
1044 pquad[
i].
mark =
true;
1047 LowestQuad( &pquad[i] ,&pquad[i].status, &pquad[i].rsnr,
true );
1048 newsnr += pquad[
i].
rsnr;
1052 LowestQuad( &pquad[lownum], &pquad[lownum].status, &pquad[lownum].rsnr,
false );
1054 if ( pquad[lownum+nx*0+1].status ==
MOT && pquad[lownum+nx*1+1].status ==
MOT
1055 && pquad[lownum+nx*2+1].status ==
MOT && pquad[lownum+nx*3+1].status ==
MOT
1056 && nsize == 4) { newsnr = 9999; pquad[lownum].
status =
MOT; }
1058 if ( pquad[lownum].rsnr > newsnr ) {
1060 pquad[lownum].
rsnr = 0;
1061 for( i=lownum+1; i<lownum+(nx*4)+1; i+=
nx ) {
1065 theRoQ->
MarkQuadx( pquad[lownum].xat, pquad[lownum].yat, nsize*2, pquad[lownum].rsnr,
qStatus[lownum].status );
1066 pquad[lownum+nx*0+1].
status = 0;
1067 pquad[lownum+nx*1+1].
status = 0;
1068 pquad[lownum+nx*2+1].
status = 0;
1069 pquad[lownum+nx*3+1].
status = 0;
1070 pquad[lownum+nx*0+1].
size = 0;
1071 pquad[lownum+nx*1+1].
size = 0;
1072 pquad[lownum+nx*2+1].
size = 0;
1073 pquad[lownum+nx*3+1].
size = 0;
1093 int i,
j, osize,
fsize,
num[
DEAD+1], *ilist, onf, ong, wtype, temp;
1094 float *flist, sRMSE, numredo;
1095 byte *idataA, *idataB;
1124 if (fsize > 64000) {
1181 Sort( flist, ilist, onf );
1209 if (dx<0||dx>15||dy<0||dy>15) {
1216 common->
Printf(
"sparseEncode: something is wrong here, dx/dy is %d,%d after being clamped\n", dx, dy);
1249 common->
Printf(
"sparseEncode: %d outside fcc limits\n", temp);
1261 Sort(flist, ilist, onf );
1323 for(i=0;i<
DEAD;i++) num[i] = 0;
1330 common->
Printf(
"sparseEncode: for 08x08 CCC = %d, FCC = %d, MOT = %d, SLD = %d, PAT = %d\n", num[
CCC], num[
FCC], num[
MOT], num[
SLD], num[
PAT]);
1332 for(i=0;i<
DEAD;i++) num[i] = 0;
1338 common->
Printf(
"sparseEncode: for 04x04 CCC = %d, FCC = %d, MOT = %d, SLD = %d, PAT = %d\n", num[CCC], num[FCC], num[MOT], num[SLD], num[PAT]);
1358 float *flist, sRMSE;
1359 byte *idataA, *idataB;
1424 for(i=0;i<
DEAD;i++) num[i] = 0;
1431 common->
Printf(
"sparseEncode: for 08x08 CCC = %d, FCC = %d, MOT = %d, SLD = %d, PAT = %d\n", num[
CCC], num[
FCC], num[
MOT], num[
SLD], num[
PAT]);
1433 for(i=0;i<
DEAD;i++) num[i] = 0;
1439 common->
Printf(
"sparseEncode: for 04x04 CCC = %d, FCC = %d, MOT = %d, SLD = %d, PAT = %d\n", num[CCC], num[FCC], num[MOT], num[SLD], num[PAT]);
1456 void codec::VQ(
const int numEntries,
const int dimension,
const unsigned char *vectors,
float *
import,
VQDATA **
codebook,
const bool optimize ) {
1459 if (numEntries <= 256) {
1463 for(
int i=0;
i<numEntries;
i++ ) {
1464 for(
int j=0;
j<dimension;
j++ ) {
1465 codebook[
i][
j] = vectors[
j+
i*dimension];
1476 int i,
j,
x, ibase, jbase;
1478 bool *inuse = (
bool *)_alloca( numEntries *
sizeof(
bool) );
1479 float *snrs = (
float *)_alloca( numEntries *
sizeof(
float) );
1480 int *indexes = (
int *)_alloca( numEntries *
sizeof(
int) );
1481 int *indexet = (
int *)_alloca( numEntries *
sizeof(
int) );
1483 int numFinalEntries = numEntries;
1484 for( i=0; i<numEntries; i++ ) {
1491 for( i=0; i<numEntries-1; i++ ) {
1492 for( j=i+1; j<numEntries; j++ ) {
1493 if (inuse[i] && inuse[j]) {
1494 if (!memcmp( &vectors[i*dimension], &vectors[j*dimension], dimension)) {
1497 import[
i] +=
import[
j];
1503 common->
Printf(
"VQ: has %d entries to process\n", numFinalEntries );
1509 if (numFinalEntries > 256) {
1513 double bestDist = HUGE;
1514 double dist, simport;
1516 int bestOtherIndex = 0;
1518 for( i=0; i<numEntries-1; i++ ) {
1522 if (numFinalEntries>8192) {
1524 }
else if (numFinalEntries>4096) {
1526 }
else if (numFinalEntries>2048) {
1528 }
else if (numFinalEntries>1024) {
1530 }
else if (numFinalEntries>512) {
1533 if (end>numEntries) {
1537 ibase = i*dimension;
1538 for( j=i+1; j<
end; j++ ) {
1541 jbase = j*dimension;
1542 for( x=0; x<dimension; x+=3 ) {
1544 r0 = (
float)vectors[ibase+x];
1545 r1 = (
float)vectors[jbase+x];
1546 g0 = (
float)vectors[ibase+x+1];
1547 g1 = (
float)vectors[jbase+x+1];
1548 b0 = (
float)vectors[ibase+x+2];
1549 b1 = (
float)vectors[jbase+x+2];
1550 dist +=
idMath::Sqrt16( (r0-r1)*(r0-r1) + (g0-g1)*(g0-g1) + (b0-b1)*(b0-b1) );
1553 int dr = vectors[ibase+
x] - vectors[jbase+
x];
1554 int dg = vectors[ibase+x+1] - vectors[jbase+x+1];
1555 int db = vectors[ibase+x+2] - vectors[jbase+x+2];
1559 simport =
import[
i] *
import[
j];
1561 if ( dist < bestDist ) {
1568 snrs[aentries] = bestDist;
1569 indexes[aentries] = bestIndex;
1570 indexet[aentries] = bestOtherIndex;
1581 bestOtherIndex = -1;
1583 for( i=0; i<aentries; i++ ) {
1584 if (inuse[indexes[i]] && inuse[indexet[i]] ) {
1585 if ( snrs[i] < bestDist ) {
1587 bestIndex = indexes[
i];
1588 bestOtherIndex = indexet[
i];
1593 if (bestIndex == -1 || !optimize) {
1598 for( i=0; i<numEntries-1; i++ ) {
1604 if (numFinalEntries>8192) {
1606 }
else if (numFinalEntries>4096) {
1608 }
else if (numFinalEntries>2048) {
1610 }
else if (numFinalEntries>1024) {
1612 }
else if (numFinalEntries>512) {
1616 if (end>numEntries) {
1619 ibase = i*dimension;
1620 for( j=i+1; j<
end; j++ ) {
1625 jbase = j*dimension;
1626 simport =
import[
i] *
import[
j];
1627 float scaledBestDist = bestDist / simport;
1628 for( x=0; x<dimension; x+=3 ) {
1630 r0 = (
float)vectors[ibase+x];
1631 r1 = (
float)vectors[jbase+x];
1632 g0 = (
float)vectors[ibase+x+1];
1633 g1 = (
float)vectors[jbase+x+1];
1634 b0 = (
float)vectors[ibase+x+2];
1635 b1 = (
float)vectors[jbase+x+2];
1636 dist +=
idMath::Sqrt16( (r0-r1)*(r0-r1) + (g0-g1)*(g0-g1) + (b0-b1)*(b0-b1) );
1639 int dr = vectors[ibase+
x] - vectors[jbase+
x];
1640 int dg = vectors[ibase+x+1] - vectors[jbase+x+1];
1641 int db = vectors[ibase+x+2] - vectors[jbase+x+2];
1643 if ( dist > scaledBestDist ) {
1649 if ( dist < bestDist ) {
1655 snrs[aentries] = bestDist;
1656 indexes[aentries] = bestIndex;
1657 indexet[aentries] = bestOtherIndex;
1664 inuse[bestIndex] =
false;
1666 import[bestOtherIndex] +=
import[bestIndex];
1667 if ((numFinalEntries&511)==0) {
1668 common->
Printf(
"VQ: has %d entries to process\n", numFinalEntries );
1671 }
while (numFinalEntries > 256);
1677 for( i=0; i<numEntries; i++ ) {
1679 ibase = i*dimension;
1680 for( x=0; x<dimension; x++ ) {
1681 codebook[onEntry][
x] = vectors[ibase +
x];
1686 if (onEntry == 255) {
1694 common->
Printf(
"VQ took %i msec\n", endMsec - startMsec );
virtual idFile * OpenFileRead(const char *relativePath, bool allowCopyFiles=true, const char *gamedir=NULL)=0
void SetPreviousImage(const char *filename, NSBitmapImageRep *timage)
NSBitmapImageRep * previousImage[2]
float GetCurrentRMSE(quadcel *pquad)
void MakePreviousImage(quadcel *pquad)
int ComputeMotionBlock(byte *old, byte *bnew, int size)
int Sys_Milliseconds(void)
idFileSystem * fileSystem
GLenum GLsizei GLenum GLenum const GLvoid * image
void WriteCodeBook(byte *codebook)
NSBitmapImageRep * newImage
void GetData(unsigned char *iData, int qSize, int startX, int startY, NSBitmapImageRep *bitmap)
static float Sqrt16(float x)
#define RGBADIST(src0, src1)
void VqData2(byte *cel, quadcel *pquad)
GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte * bitmap
void VqData4(byte *cel, quadcel *pquad)
void VQ(const int numEntries, const int dimension, const unsigned char *vectors, float *snr, VQDATA **codebook, const bool optimize)
int AddQuad(quadcel *pquad, int lownum)
const char * CurrentFilename(void)
int GetCurrentQuadOutputSize(quadcel *pquad)
void LowestQuad(quadcel *qtemp, int *status, float *snr, int bweigh)
void FvqData(byte *bitmap, int size, int realx, int realy, quadcel *pquad, bool clamp)
virtual idFile * OpenFileWrite(const char *relativePath, const char *basePath="fs_savepath")=0
virtual int Read(void *buffer, int len)
void QuadX(int startX, int startY, int quadSize)
void Segment(int *alist, float *flist, int numElements, float rmse)
GLubyte GLubyte GLubyte a
virtual void UpdateScreen(bool outOfSequence=true)=0
virtual void Printf(const char *fmt,...) id_attribute((format(printf
GLdouble GLdouble GLdouble y2
NSBitmapImageRep * CurrentImage(void)
GLfloat GLfloat GLfloat GLfloat nx
void MarkQuadx(int xat, int yat, int size, float cerror, int choice)
void Sort(float *list, int *intIndex, int numElements)
GLdouble GLdouble GLdouble r
int BestCodeword(unsigned char *tempvector, int dimension, VQDATA **codebook)
virtual int Write(const void *buffer, int len)
int NormalFrameSize(void)
void * Mem_ClearedAlloc(const int size)
int samplesPerPixel(void)
float glimit(const float val)
void * Mem_Alloc(const int size)
void WriteFrame(quadcel *pquad)
virtual void CloseFile(idFile *f)=0
virtual void Error(const char *fmt,...) id_attribute((format(printf
float Snr(byte *old, byte *bnew, int size)
int sprintf(idStr &string, const char *fmt,...)
void VqData8(byte *cel, quadcel *pquad)