FDCT Transformation of luminance signals
Storage array for @param data luminance signal
void Compressencode::standardfdct (BYTE data[matrixsize][matrixsize])
{
BYTE Output[matrixsize][matrixsize];
Double alpha, Beta;
Short U = 0, v = 0;
Short x = 0, y = 0;
for (v = 0; v < matrixsize; ++v) {//Vertical
for (U = 0; u < matrixsize; ++u) {//Horizontal
Set C (U), C (v) factor
Alpha = 1;
if (U = = 0) Alpha = sqrt (1.0/2.0);
beta = 1;
if (v = = 0) Beta = sqrt (1.0/2.0);
Double tmp = 0.0;
for (x = 0; x < matrixsize; ++x) {
for (y = 0; y < matrixsize; ++y) {
The variable value of the DCT receives is [-128,127], so the variables are reduced by 128
TMP + = (Data[x][y]-128)
*cos ((2 * x + 1) *u*m_pi/(2.0*matrixsize))
*cos ((2 * y + 1) *v*m_pi/(2.0*matrixsize));
}
}
OUTPUT[U][V] = round_double ((ALPHA*BETA/4) *tmp);
}
Write the transformation results back to the original buffer
memset (data, 0, matrixsize*matrixsize * sizeof (BYTE));
memcpy (data, output, matrixsize*matrixsize * sizeof (BYTE));
}
}
FDCT Transformation Formula method