diff --git a/source/src/jpegenc.h b/source/src/jpegenc.h index d7b1e315..eec1fa4e 100644 --- a/source/src/jpegenc.h +++ b/source/src/jpegenc.h @@ -22,7 +22,7 @@ typedef struct { BYTE length; WORD value;} bitstring; #define writeword(w) writebyte((w)/256);writebyte((w)%256); struct APP0infotype -{ +{ WORD marker; WORD length; BYTE JFIFsignature[5]; @@ -69,7 +69,7 @@ struct SOF0infotype BYTE IdCr; BYTE HVCr; BYTE QTCr; - + SOF0infotype() { marker = 0xFFC0; @@ -97,7 +97,7 @@ struct DQTinfotype BYTE QTYinfo; BYTE Ytable[64]; BYTE QTCbinfo; - BYTE Cbtable[64]; + BYTE Cbtable[64]; DQTinfotype() { marker = 0xFFDB; @@ -124,7 +124,7 @@ struct DHTinfotype BYTE CbDC_values[12]; BYTE HTCbACinfo; BYTE CbAC_nrcodes[16]; - BYTE CbAC_values[162]; + BYTE CbAC_values[162]; DHTinfotype() { marker = 0xFFC4; @@ -155,7 +155,7 @@ struct SOSinfotype BYTE HTCb; BYTE IdCr; BYTE HTCr; - BYTE Ss,Se,Bf; + BYTE Ss,Se,Bf; SOSinfotype() { marker = 0xFFDA; @@ -172,7 +172,7 @@ struct SOSinfotype Bf = 0; } }; - + class jpegenc { private: @@ -188,13 +188,13 @@ class jpegenc static BYTE std_ac_chrominance_nrcodes[]; static BYTE std_ac_chrominance_values[]; static WORD mask[]; - + APP0infotype APP0info; SOF0infotype SOF0info; DQTinfotype DQTinfo; SOSinfotype SOSinfo; DHTinfotype DHTinfo; - + BYTE bytenew; SBYTE bytepos; @@ -215,13 +215,13 @@ class jpegenc void precalculate_YCbCr_tables(); void prepare_quant_tables(); void fdct_and_quantization(SBYTE *data, float *fdtbl, SWORD *outdata); - - void process_DU(SBYTE *ComponentDU, float *fdtbl,SWORD *DC, bitstring *HTDC, bitstring *HTAC); + + void process_DU(SBYTE *ComponentDU, float *fdtbl,SWORD *DC, bitstring *HTDC, bitstring *HTAC); void load_data_units_from_RGB_buffer(WORD xpos, WORD ypos); - + void main_encoder(void); void init_all(int qfactor); - + public: jpegenc() { @@ -408,11 +408,11 @@ void jpegenc::set_quant_table(BYTE *basic_table, BYTE scale_factor, BYTE *newtab { BYTE i; long temp; - for (i=0; i<64; i++) + for (i=0; i<64; i++) { temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; if (temp <= 0L) temp = 1L; - if (temp > 255L) temp = 255L; + if (temp > 255L) temp = 255L; newtable[zigzag[i]] = (BYTE) temp; } } @@ -508,7 +508,7 @@ void jpegenc::write_comment(BYTE *comment) writeword(0xFFFE); length = (WORD) strlen((const char *)comment); writeword(length + 2); - for (i=0; i= 0) { - if (value & mask[posval]) + if (value & mask[posval]) bytenew |= mask[bytepos]; posval--; bytepos--; - if (bytepos < 0) - { - if (bytenew == 0xFF) + if (bytepos < 0) + { + if (bytenew == 0xFF) { writebyte(0xFF); writebyte(0); @@ -544,11 +544,11 @@ void jpegenc::compute_Huffman_table(BYTE *nrcodes, BYTE *std_table, bitstring *H BYTE k,j; BYTE pos_in_table; WORD codevalue; - codevalue = 0; + codevalue = 0; pos_in_table = 0; for (k=1; k<=16; k++) { - for (j=1; j<=nrcodes[k]; j++) + for (j=1; j<=nrcodes[k]; j++) { HT[std_table[pos_in_table]].value = codevalue; HT[std_table[pos_in_table]].length = k; @@ -580,22 +580,22 @@ void jpegenc::set_numbers_category_and_bitcode() BYTE cat; category_alloc = (BYTE *)malloc(65535*sizeof(BYTE)); if (category_alloc == NULL) exitmessage("Not enough memory."); - category = category_alloc + 32767; + category = category_alloc + 32767; bitcode_alloc=(bitstring *)malloc(65535*sizeof(bitstring)); if (bitcode_alloc==NULL) exitmessage("Not enough memory."); bitcode = bitcode_alloc + 32767; nrlower = 1; nrupper = 2; - for (cat=1; cat<=15; cat++) + for (cat=1; cat<=15; cat++) { for (nr=nrlower; nr= 0; ctr--) + for (ctr = 7; ctr >= 0; ctr--) { tmp0 = dataptr[0] + dataptr[7]; tmp7 = dataptr[0] - dataptr[7]; @@ -695,7 +695,7 @@ void jpegenc::fdct_and_quantization(SBYTE *data, float *fdtbl, SWORD *outdata) dataptr += 8; } dataptr = datafloat; - for (ctr = 7; ctr >= 0; ctr--) + for (ctr = 7; ctr >= 0; ctr--) { tmp0 = dataptr[0] + dataptr[56]; tmp7 = dataptr[0] - dataptr[56]; @@ -729,7 +729,7 @@ void jpegenc::fdct_and_quantization(SBYTE *data, float *fdtbl, SWORD *outdata) dataptr[56] = z11 - z4; dataptr++; } - for (i = 0; i < 64; i++) + for (i = 0; i < 64; i++) { temp = datafloat[i] * fdtbl[i]; outdata[i] = (SWORD) ((SWORD)(temp + 16384.5) - 16384); @@ -751,7 +751,7 @@ void jpegenc::process_DU(SBYTE *ComponentDU,float *fdtbl,SWORD *DC, bitstring *H Diff = DU[0] - *DC; *DC = DU[0]; if (Diff == 0) writebits(HTDC[0]); - else + else { writebits(HTDC[category[Diff]]); writebits(bitcode[Diff]); @@ -763,7 +763,7 @@ void jpegenc::process_DU(SBYTE *ComponentDU,float *fdtbl,SWORD *DC, bitstring *H startpos = i; for (; (DU[i]==0) && (i<=end0pos); i++) ; nrzeroes = i - startpos; - if (nrzeroes >= 16) + if (nrzeroes >= 16) { for (nrmarker=1; nrmarker<=nrzeroes/16; nrmarker++) writebits(M16zeroes); nrzeroes = nrzeroes%16; @@ -839,7 +839,7 @@ int jpegenc::encode(const char *filename, SDL_Surface *image, int jpegquality) set_numbers_category_and_bitcode(); precalculate_YCbCr_tables(); prepare_quant_tables(); - + SOF0info.width = width; SOF0info.height = height; @@ -856,7 +856,7 @@ int jpegenc::encode(const char *filename, SDL_Surface *image, int jpegquality) main_encoder(); - if (bytepos >= 0) + if (bytepos >= 0) { fillbits.length = bytepos + 1; fillbits.value = (1<<(bytepos+1)) - 1; diff --git a/source/src/scale.h b/source/src/scale.h index 6563cd15..1aecabfe 100644 --- a/source/src/scale.h +++ b/source/src/scale.h @@ -22,17 +22,17 @@ static void FUNCNAME(shifttexture)(uchar *src, uint sw, uint sh, uchar *dst, uin for(uchar *yend = &src[sh*stride]; src < yend;) { for(uchar *xend = &src[stride]; src < xend; src += wfrac*BPP, dst += BPP) - { + { #define OP(c, n) c##t = 0 DEFPIXEL #undef OP - for(uchar *ycur = src, *xend = &ycur[wfrac*BPP], *yend = &src[hfrac*stride]; - ycur < yend; + for(uchar *ycur = src, *xend = &ycur[wfrac*BPP], *yend = &src[hfrac*stride]; + ycur < yend; ycur += stride, xend += stride) { for(uchar *xcur = ycur; xcur < xend; xcur += BPP) { - #define OP(c, n) c##t += xcur[n] + #define OP(c, n) c##t += xcur[n] PIXELOP #undef OP } @@ -41,7 +41,7 @@ static void FUNCNAME(shifttexture)(uchar *src, uint sw, uint sh, uchar *dst, uin PIXELOP #undef OP } - src += (hfrac-1)*stride; + src += (hfrac-1)*stride; } } @@ -50,7 +50,7 @@ static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uchar *dst, uin uint stride = sw*BPP, wfrac = (sw<<12)/dw, hfrac = (sh<<12)/dh; for(uint dy = 0, y = 0, yi = 0; dy < dh; dy++) { - uint y2 = y + hfrac, yi2 = y2>>12, + uint y2 = y + hfrac, yi2 = y2>>12, h = y2 - y, ih = yi2 - yi, ylow, yhigh; if(yi < yi2) { ylow = 0x1000U - (y&0xFFFU); yhigh = y2&0xFFFU; } @@ -58,30 +58,30 @@ static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uchar *dst, uin for(uint dx = 0, x = 0, xi = 0; dx < dw; dx++) { - uint x2 = x + wfrac, xi2 = x2>>12, + uint x2 = x + wfrac, xi2 = x2>>12, w = x2 - x, iw = xi2 - xi, iy = 0, - xlow, xhigh; + xlow, xhigh; if(xi < xi2) { xlow = 0x1000U - (x&0xFFFU); xhigh = x2&0xFFFU; } else { xlow = x2 - x; xhigh = 0; } #define OP(c, n) c##t = 0 DEFPIXEL #undef OP - for(uchar *ycur = &src[xi*BPP], *xend = &ycur[max(iw, 1U)*BPP], *yend = &ycur[stride*(max(ih, 1U) + (yhigh ? 1 : 0))]; - ycur < yend; + for(uchar *ycur = &src[xi*BPP], *xend = &ycur[max(iw, 1U)*BPP], *yend = &ycur[stride*(max(ih, 1U) + (yhigh ? 1 : 0))]; + ycur < yend; ycur += stride, xend += stride, iy++) { #define OP(c, n) c = (ycur[n]*xlow)>>12 DEFPIXEL #undef OP - for(uchar *xcur = &ycur[BPP]; xcur < xend; xcur += BPP) + for(uchar *xcur = &ycur[BPP]; xcur < xend; xcur += BPP) { - #define OP(c, n) c += xcur[n] + #define OP(c, n) c += xcur[n] PIXELOP #undef OP } - if(xhigh) - { + if(xhigh) + { #define OP(c, n) c += (xend[n]*xhigh)>>12 PIXELOP #undef OP @@ -89,7 +89,7 @@ static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uchar *dst, uin #define OP(c, n) c = (c<<12)/w PIXELOP #undef OP - if(!iy) + if(!iy) { #define OP(c, n) c##t += (c*ylow)>>12 PIXELOP @@ -101,8 +101,8 @@ static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uchar *dst, uin PIXELOP #undef OP } - else - { + else + { #define OP(c, n) c##t += c PIXELOP #undef OP @@ -118,7 +118,7 @@ static void FUNCNAME(scaletexture)(uchar *src, uint sw, uint sh, uchar *dst, uin xi = xi2; } - src += ih*stride; + src += ih*stride; y = y2; yi = yi2; } diff --git a/source/src/shadow.cpp b/source/src/shadow.cpp index 14ed3b91..9a8cb238 100644 --- a/source/src/shadow.cpp +++ b/source/src/shadow.cpp @@ -8,8 +8,6 @@ int stenciling = 0; VAR(shadowclip, 0, 1, 1); VAR(shadowtile, 0, 1, 1); -const int dbgtiles = 0; -//VAR(dbgtiles, 0, 0, 1); VAR(shadowcasters, 1, 0, 0); #define SHADOWROWS 64 @@ -417,25 +415,9 @@ void drawstencilshadows() glPushMatrix(); glLoadIdentity(); - static uint debugtiles[SHADOWROWS+1]; - if(dbgtiles) memcpy(debugtiles, shadowtiles, sizeof(debugtiles)); - rendershadowtiles(); - if(dbgtiles) - { - glDisable(GL_STENCIL_TEST); - glColor3f(0.5f, 1, 0.5f); - memcpy(shadowtiles, debugtiles, sizeof(debugtiles)); - rendershadowtiles(); - glColor3f(0, 0, 1); - glDisable(GL_BLEND); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - memcpy(shadowtiles, debugtiles, sizeof(debugtiles)); - rendershadowtiles(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - else glDisable(GL_BLEND); + glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glLoadIdentity();