📄 img_fdct_8x8.h
字号:
for (j = 0; j < 8; j++)
{
// ------------------------------------------------ //
// Load the spatial-domain samples. //
// ------------------------------------------------ //
f0 = dct_io_ptr[ 0];
f1 = dct_io_ptr[ 8];
f2 = dct_io_ptr[16];
f3 = dct_io_ptr[24];
f4 = dct_io_ptr[32];
f5 = dct_io_ptr[40];
f6 = dct_io_ptr[48];
f7 = dct_io_ptr[56];
// ------------------------------------------------ //
// Stage 1: Separate into even and odd halves. //
// ------------------------------------------------ //
g0 = f0 + f7; h2 = f0 - f7;
g1 = f1 + f6; h3 = f1 - f6;
h1 = f2 + f5; g3 = f2 - f5;
h0 = f3 + f4; g2 = f3 - f4;
// ------------------------------------------------ //
// Stage 2 //
// ------------------------------------------------ //
p0 = g0 + h0; r0 = g0 - h0;
p1 = g1 + h1; r1 = g1 - h1;
q1 = g2; s1 = h2;
s0a= h3 + g3; q0a= h3 - g3;
s0 = (s0a * c0 + 0x7FFF) >> 16;
q0 = (q0a * c0 + 0x7FFF) >> 16;
// ------------------------------------------------ //
// Stage 3 //
// ------------------------------------------------ //
P0 = p0 + p1; P1 = p0 - p1;
R1 = c6 * r1 + c2 * r0; R0 = c6 * r0 - c2 * r1;
Q1 = q1 + q0; Q0 = q1 - q0;
S1 = s1 + s0; S0 = s1 - s0;
// ------------------------------------------------ //
// Stage 4 //
// ------------------------------------------------ //
F0 = P0; F4 = P1;
F2 = R1; F6 = R0;
F1 = c7 * Q1 + c1 * S1; F7 = c7 * S1 - c1 * Q1;
F5 = c3 * Q0 + c5 * S0; F3 = c3 * S0 - c5 * Q0;
// ------------------------------------------------ //
// Store the frequency domain results. //
// ------------------------------------------------ //
dct_io_ptr[ 0] = F0;
dct_io_ptr[ 8] = F1 >> 13;
dct_io_ptr[16] = F2 >> 13;
dct_io_ptr[24] = F3 >> 13;
dct_io_ptr[32] = F4;
dct_io_ptr[40] = F5 >> 13;
dct_io_ptr[48] = F6 >> 13;
dct_io_ptr[56] = F7 >> 13;
dct_io_ptr++;
}
// ---------------------------------------------------- //
// Update pointer to next 8x8 FDCT block. //
// ---------------------------------------------------- //
dct_io_ptr += 56;
}
// -------------------------------------------------------- //
// Perform Horizontal 1-D FDCT on each 8x8 block. //
// -------------------------------------------------------- //
dct_io_ptr = dct_data;
for (i = 0; i < 8 * num_fdcts; i++)
{
// ---------------------------------------------------- //
// Load the spatial-domain samples. //
// ---------------------------------------------------- //
f0 = dct_io_ptr[0];
f1 = dct_io_ptr[1];
f2 = dct_io_ptr[2];
f3 = dct_io_ptr[3];
f4 = dct_io_ptr[4];
f5 = dct_io_ptr[5];
f6 = dct_io_ptr[6];
f7 = dct_io_ptr[7];
// ---------------------------------------------------- //
// Stage 1: Separate into even and odd halves. //
// ---------------------------------------------------- //
g0 = f0 + f7; h2 = f0 - f7;
g1 = f1 + f6; h3 = f1 - f6;
h1 = f2 + f5; g3 = f2 - f5;
h0 = f3 + f4; g2 = f3 - f4;
// ---------------------------------------------------- //
// Stage 2 //
// ---------------------------------------------------- //
p0 = g0 + h0; r0 = g0 - h0;
p1 = g1 + h1; r1 = g1 - h1;
q1 = g2; s1 = h2;
s0a= h3 + g3; q0a= h3 - g3;
q0 = (q0a * c0 + 0x7FFF) >> 16;
s0 = (s0a * c0 + 0x7FFF) >> 16;
// ---------------------------------------------------- //
// Stage 3 //
// ---------------------------------------------------- //
P0 = p0 + p1; P1 = p0 - p1;
R1 = c6 * r1 + c2 * r0; R0 = c6 * r0 - c2 * r1;
Q1 = q1 + q0; Q0 = q1 - q0;
S1 = s1 + s0; S0 = s1 - s0;
// ---------------------------------------------------- //
// Stage 4 //
// ---------------------------------------------------- //
F0 = P0; F4 = P1;
F2 = R1; F6 = R0;
F1 = c7 * Q1 + c1 * S1; F7 = c7 * S1 - c1 * Q1;
F5 = c3 * Q0 + c5 * S0; F3 = c3 * S0 - c5 * Q0;
// ---------------------------------------------------- //
// Round and truncate values. //
// //
// Note: F0 and F4 have different rounding since no //
// MPYs have been applied to either term. Also, F0's //
// rounding is slightly different to offset the //
// truncation effects from the horizontal pass (which //
// does not round). //
// ---------------------------------------------------- //
F0r = (F0 + 0x0006) >> 3;
F1r = (F1 + 0x7FFF) >> 16;
F2r = (F2 + 0x7FFF) >> 16;
F3r = (F3 + 0x7FFF) >> 16;
F4r = (F4 + 0x0004) >> 3;
F5r = (F5 + 0x7FFF) >> 16;
F6r = (F6 + 0x7FFF) >> 16;
F7r = (F7 + 0x7FFF) >> 16;
// ---------------------------------------------------- //
// Store the results //
// ---------------------------------------------------- //
dct_io_ptr[0] = F0r;
dct_io_ptr[1] = F1r;
dct_io_ptr[2] = F2r;
dct_io_ptr[3] = F3r;
dct_io_ptr[4] = F4r;
dct_io_ptr[5] = F5r;
dct_io_ptr[6] = F6r;
dct_io_ptr[7] = F7r;
// ---------------------------------------------------- //
// Update pointer to next FDCT row. //
// ---------------------------------------------------- //
dct_io_ptr += 8;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -