Created
March 13, 2017 20:30
-
-
Save feliwir/8aadbfdaca177ec67ebd6abc6d31b222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void VP62_IDCT8x8(PVP62 pVP62, int b){ | |
/************************************************************/ | |
/* */ | |
/* Inverse DCT defined as: */ | |
/* */ | |
/* sqrt(2) 7 PI */ | |
/* Qj = X0 * ------- + Sum Xn * Cos( -- * n*(2*j+1) ) */ | |
/* 2 n=1 16 */ | |
/* */ | |
/************************************************************/ | |
short *output = pVP62->block8x8[b]; | |
int c, row, col, src = 0, dst = 0, scoeff[64] /* Scaled coeffs */; | |
int x0, x1, x2, x3, x4, x5, x6, x7, t0, t1, t2, t3, t4, t5, t6, t7, u0, u1, u2, u3, u4, u5, v0, v1, v2, v3; | |
static unsigned char zigzag[64] = { 0, 1, 8, 16, 9, 2, 3, 10, | |
17, 24, 32, 25, 18, 11, 4, 5, | |
12, 19, 26, 33, 40, 48, 41, 34, | |
27, 20, 13, 6, 7, 14, 21, 28, | |
35, 42, 49, 56, 57, 50, 43, 36, | |
29, 22, 15, 23, 30, 37, 44, 51, | |
58, 59, 52, 45, 38, 31, 39, 46, | |
53, 60, 61, 54, 47, 55, 62, 63 }; | |
for(c = 0; c < 64; c++){ | |
scoeff[zigzag[c]] = pVP62->coeff420[b][c] * pVP62->coeffScale[c]; | |
} | |
for(row = 0; row < 8; row++){ | |
x0 = scoeff[src]; | |
x1 = scoeff[src + 1]; | |
x2 = scoeff[src + 2]; | |
x3 = scoeff[src + 3]; | |
x4 = scoeff[src + 4]; | |
x5 = scoeff[src + 5]; | |
x6 = scoeff[src + 6]; | |
x7 = scoeff[src + 7]; | |
if (x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7){ | |
t0 = ((COS_1_16 * x1) >> 16) + ((COS_7_16 * x7) >> 16); | |
t1 = ((COS_7_16 * x1) >> 16) - ((COS_1_16 * x7) >> 16); | |
t2 = ((COS_3_16 * x3) >> 16) + ((COS_5_16 * x5) >> 16); | |
t3 = ((COS_3_16 * x5) >> 16) - ((COS_5_16 * x3) >> 16); | |
u0 = (COS_4_16 * (t0 - t2)) >> 16; | |
u1 = (COS_4_16 * (t1 - t3)) >> 16; | |
u2 = t0 + t2; | |
u3 = t1 + t3; | |
t4 = (COS_4_16 * (x0 + x4)) >> 16; | |
t5 = (COS_4_16 * (x0 - x4)) >> 16; | |
t6 = ((COS_2_16 * x2) >> 16) + ((COS_6_16 * x6) >> 16); | |
t7 = ((COS_6_16 * x2) >> 16) - ((COS_2_16 * x6) >> 16); | |
u4 = t4 - t6; | |
u5 = t4 + t6; | |
v0 = t5 + u0; | |
v1 = u1 - t7; | |
v2 = t5 - u0; | |
v3 = u1 + t7; | |
scoeff[src] = u5 + u2; | |
scoeff[src + 7] = u5 - u2; | |
scoeff[src + 1] = v0 + v3; | |
scoeff[src + 2] = v0 - v3; | |
scoeff[src + 3] = u4 + u3; | |
scoeff[src + 4] = u4 - u3; | |
scoeff[src + 5] = v2 + v1; | |
scoeff[src + 6] = v2 - v1; | |
} | |
src += 8; | |
} | |
src = 0; | |
for(col = 0; col < 8; col++){ | |
x0 = scoeff[src]; | |
x1 = scoeff[src + 8]; | |
x2 = scoeff[src + 16]; | |
x3 = scoeff[src + 24]; | |
x4 = scoeff[src + 32]; | |
x5 = scoeff[src + 40]; | |
x6 = scoeff[src + 48]; | |
x7 = scoeff[src + 56]; | |
if(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7){ | |
t0 = ((COS_1_16 * x1) >> 16) + ((COS_7_16 * x7) >> 16); | |
t1 = ((COS_7_16 * x1) >> 16) - ((COS_1_16 * x7) >> 16); | |
t2 = ((COS_3_16 * x3) >> 16) + ((COS_5_16 * x5) >> 16); | |
t3 = ((COS_3_16 * x5) >> 16) - ((COS_5_16 * x3) >> 16); | |
u0 = (COS_4_16 * (t0 - t2)) >> 16; | |
u1 = (COS_4_16 * (t1 - t3)) >> 16; | |
u2 = t0 + t2; | |
u3 = t1 + t3; | |
t4 = (COS_4_16 * (x0 + x4)) >> 16; | |
t5 = (COS_4_16 * (x0 - x4)) >> 16; | |
t6 = ((COS_2_16 * x2) >> 16) + ((COS_6_16 * x6) >> 16); | |
t7 = ((COS_6_16 * x2) >> 16) - ((COS_2_16 * x6) >> 16); | |
u4 = t4 - t6; | |
u5 = t4 + t6; | |
v0 = t5 + u0; | |
v1 = u1 - t7; | |
v2 = t5 - u0; | |
v3 = u1 + t7; | |
output[dst] = (short)((u5 + u2 + 8) >> 4); | |
output[dst + 56] = (short)((u5 - u2 + 8) >> 4); | |
output[dst + 8] = (short)((v0 + v3 + 8) >> 4); | |
output[dst + 16] = (short)((v0 - v3 + 8) >> 4); | |
output[dst + 24] = (short)((u4 + u3 + 8) >> 4); | |
output[dst + 32] = (short)((u4 - u3 + 8) >> 4); | |
output[dst + 40] = (short)((v2 + v1 + 8) >> 4); | |
output[dst + 48] = (short)((v2 - v1 + 8) >> 4); | |
} | |
else{ | |
output[dst] = 0; | |
output[dst + 8] = 0; | |
output[dst + 16] = 0; | |
output[dst + 24] = 0; | |
output[dst + 32] = 0; | |
output[dst + 40] = 0; | |
output[dst + 48] = 0; | |
output[dst + 56] = 0; | |
} | |
src++; | |
dst++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment