Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/apps/mplayerc/jpeg.cpp')
-rw-r--r--src/apps/mplayerc/jpeg.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/apps/mplayerc/jpeg.cpp b/src/apps/mplayerc/jpeg.cpp
index bcb32c098..85164bb0a 100644
--- a/src/apps/mplayerc/jpeg.cpp
+++ b/src/apps/mplayerc/jpeg.cpp
@@ -2,7 +2,7 @@
* $Id$
*
* (C) 2003-2006 Gabest
- * (C) 2006-2010 see AUTHORS
+ * (C) 2006-2011 see AUTHORS
*
* This file is part of mplayerc.
*
@@ -29,7 +29,7 @@
bool CJpegEncoder::PutBit(int b, int n)
{
- if(n > 24 || n <= 0) {
+ if (n > 24 || n <= 0) {
return(false);
}
@@ -37,10 +37,10 @@ bool CJpegEncoder::PutBit(int b, int n)
m_bbuff |= b & ((1 << n) - 1);
m_bwidth += n;
- while(m_bwidth >= 8) {
+ while (m_bwidth >= 8) {
BYTE c = (BYTE)(m_bbuff >> (m_bwidth - 8));
PutByte(c);
- if(c == 0xff) {
+ if (c == 0xff) {
PutByte(0);
}
m_bwidth -= 8;
@@ -51,10 +51,10 @@ bool CJpegEncoder::PutBit(int b, int n)
void CJpegEncoder::Flush()
{
- if(m_bwidth > 0) {
+ if (m_bwidth > 0) {
BYTE c = m_bbuff << (8 - m_bwidth);
PutByte(c);
- if(c == 0xff) {
+ if (c == 0xff) {
PutByte(0);
}
}
@@ -66,15 +66,15 @@ void CJpegEncoder::Flush()
int CJpegEncoder::GetBitWidth(short q)
{
- if(q == 0) {
+ if (q == 0) {
return(0);
}
- if(q < 0) {
+ if (q < 0) {
q = -q;
}
int width = 15;
- for(; !(q&0x4000); q <<= 1, width--) {
+ for (; !(q&0x4000); q <<= 1, width--) {
;
}
return(width);
@@ -97,7 +97,7 @@ void CJpegEncoder::WriteDQT()
PutByte(size>>8);
PutByte(size&0xff);
- for(int c = 0; c < 2; c++) {
+ for (int c = 0; c < 2; c++) {
PutByte(c);
PutBytes(quanttbl[c], 64);
}
@@ -145,13 +145,13 @@ void CJpegEncoder::WriteDHT()
PutByte(0x00); // tbl class (DC) | tbl id
PutBytes(DCVLC_NumByLength[0], 16);
- for(int i = 0; i < 12; i++) {
+ for (int i = 0; i < 12; i++) {
PutByte(i);
}
PutByte(0x01); // tbl class (DC) | tbl id
PutBytes(DCVLC_NumByLength[1], 16);
- for(int i = 0; i < 12; i++) {
+ for (int i = 0; i < 12; i++) {
PutByte(i);
}
@@ -196,41 +196,41 @@ void CJpegEncoder::WriteSOS()
static float cosuv[8][8][8][8];
// oh yeah, we don't need no fast dct :)
- for(int v = 0; v < 8; v++)
- for(int u = 0; u < 8; u++)
- for(int j = 0; j < 8; j++)
- for(int i = 0; i < 8; i++) {
+ for (int v = 0; v < 8; v++)
+ for (int u = 0; u < 8; u++)
+ for (int j = 0; j < 8; j++)
+ for (int i = 0; i < 8; i++) {
cosuv[v][u][j][i] = (float)(cos((2*i+1)*u*PI/16) * cos((2*j+1)*v*PI/16));
}
int prevDC[3] = {0, 0, 0};
- for(int y = 0; y < m_h; y += 8) {
+ for (int y = 0; y < m_h; y += 8) {
int jj = min(m_h - y, 8);
- for(int x = 0; x < m_w; x += 8) {
+ for (int x = 0; x < m_w; x += 8) {
int ii = min(m_w - x, 8);
- for(int c = 0; c < ColorComponents; c++) {
+ for (int c = 0; c < ColorComponents; c++) {
int cc = !!c;
int ACs = 0;
static short block[64];
- for(int zigzag = 0; zigzag < 64; zigzag++) {
+ for (int zigzag = 0; zigzag < 64; zigzag++) {
BYTE u = zigzagU[zigzag];
BYTE v = zigzagV[zigzag];
float F = 0;
/*
- for(int j = 0; j < jj; j++)
- for(int i = 0; i < ii; i++)
+ for (int j = 0; j < jj; j++)
+ for (int i = 0; i < ii; i++)
F += (signed char)m_p[((y+j)*m_w + (x+i))*4 + c] * cosuv[v][u][j][i];
*/
- for(int j = 0; j < jj; j++) {
+ for (int j = 0; j < jj; j++) {
signed char* p = (signed char*)&m_p[((y+j)*m_w + x)*4 + c];
- for(int i = 0; i < ii; i++, p += 4) {
+ for (int i = 0; i < ii; i++, p += 4) {
F += *p * cosuv[v][u][j][i];
}
}
@@ -247,21 +247,21 @@ void CJpegEncoder::WriteSOS()
int size = GetBitWidth(DC);
PutBit(DCVLC[cc][size], DCVLC_Size[cc][size]);
- if(DC < 0) {
+ if (DC < 0) {
DC = DC - 1;
}
PutBit(DC, size);
int j;
- for(j = 64; j > 1 && !block[j-1]; j--) {
+ for (j = 64; j > 1 && !block[j-1]; j--) {
;
}
- for(int i = 1; i < j; i++) {
+ for (int i = 1; i < j; i++) {
short AC = block[i];
- if(AC == 0) {
- if(++ACs == 16) {
+ if (AC == 0) {
+ if (++ACs == 16) {
PutBit(ACVLC[cc][15][0], ACVLC_Size[cc][15][0]);
ACs = 0;
}
@@ -269,7 +269,7 @@ void CJpegEncoder::WriteSOS()
int size = GetBitWidth(AC);
PutBit(ACVLC[cc][ACs][size], ACVLC_Size[cc][ACs][size]);
- if(AC < 0) {
+ if (AC < 0) {
AC--;
}
PutBit(AC, size);
@@ -278,7 +278,7 @@ void CJpegEncoder::WriteSOS()
}
}
- if(j < 64) {
+ if (j < 64) {
PutBit(ACVLC[cc][0][0], ACVLC_Size[cc][0][0]);
}
}
@@ -308,7 +308,7 @@ bool CJpegEncoder::Encode(const BYTE* dib)
int bpp = bi->bmiHeader.biBitCount;
- if(bpp != 16 && bpp != 24 && bpp != 32) { // 16 & 24 not tested!!! there may be some alignment problems when the row size is not 4*something in bytes
+ if (bpp != 16 && bpp != 24 && bpp != 32) { // 16 & 24 not tested!!! there may be some alignment problems when the row size is not 4*something in bytes
return false;
}
@@ -317,8 +317,8 @@ bool CJpegEncoder::Encode(const BYTE* dib)
m_p = DNew BYTE[m_w*m_h*4];
const BYTE* src = dib + sizeof(bi->bmiHeader);
- if(bi->bmiHeader.biBitCount <= 8) {
- if(bi->bmiHeader.biClrUsed) {
+ if (bi->bmiHeader.biBitCount <= 8) {
+ if (bi->bmiHeader.biClrUsed) {
src += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
} else {
src += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
@@ -334,7 +334,7 @@ bool CJpegEncoder::Encode(const BYTE* dib)
(BYTE*)src + srcpitch*(m_h-1), -srcpitch, bpp);
BYTE* p = m_p;
- for(BYTE* e = p + m_h*dstpitch; p < e; p += 4) {
+ for (BYTE* e = p + m_h*dstpitch; p < e; p += 4) {
int r = p[2], g = p[1], b = p[0];
p[0] = (BYTE)min(max(0.2990*r+0.5870*g+0.1140*b, 0), 255) - 128;
@@ -342,9 +342,9 @@ bool CJpegEncoder::Encode(const BYTE* dib)
p[2] = (BYTE)min(max(0.5000*r-0.4187*g-0.0813*b + 128, 0), 255) - 128;
}
- if(quanttbl[0][0] == 16) {
- for(int i = 0; i < countof(quanttbl); i++)
- for(int j = 0; j < countof(quanttbl[0]); j++) {
+ if (quanttbl[0][0] == 16) {
+ for (int i = 0; i < countof(quanttbl); i++)
+ for (int j = 0; j < countof(quanttbl[0]); j++) {
quanttbl[i][j] >>= 2; // the default quantization table contains a little too large values
}
}
@@ -382,7 +382,7 @@ bool CJpegEncoderFile::PutBytes(const void* pData, size_t len)
bool CJpegEncoderFile::Encode(const BYTE* dib)
{
m_file = _tfopen(m_fn, _T("wb"));
- if(!m_file) {
+ if (!m_file) {
return false;
}
bool ret = __super::Encode(dib);