#include "stdio.h"
#include "fstream.h"
/**********************************************************************
*
* Name: IDCT
* Description: perform idct function
*
* Input: block number
*
* Returns: none
* Side effects:
*
* Date: 2005.11.08
*
***********************************************************************/
void main()
{
const short c1 = 0x0B19, c2 = 0x0A74, c3 = 0x0968;
const short c5 = 0x0649, c6 = 0x0454, c7 = 0x0235;
const int c4_shift = 11;
const int round1 = 256, round2 = 32768;
const int trunc1 = 9, trunc2 = 16;
int io_ptr[64]={72,23,88,83,90,1,42,130,
83,99,34,21,65,23,33,9,
71,43,90,223,51,83,99,1,
88,109,190,66,93,43,78,11,
90,123,20,83,90,12,1,2,
99,32,43,84,83,26,222,245,
1,79,255,93,12,53,66,87,
90,80,31,83,12,34,92,100};
int i,j, count=0;;
short X0, X1, X2, X3, X4, X5, X6, X7; /* Freq domain terms */
int P0, P1, p0, p1, r0, r1; /* Even-half temp */
int g0, g1, h1, h0; /* Even-half result */
int g2, g3, h3, h2; /* Odd-half result */
int x0, x1, x2, x3, x4, x5, x6, x7; /* Resulting samples */
int x0t,x1t,x2t,x3t,x4t,x5t,x6t,x7t; /* Truncated result */
int x0s,x1s,x2s,x3s,x4s,x5s,x6s,x7s; /* Saturated result */
/* ---------------------------------------------------------- */
/* Avoid running the code if we don't have any IDCTs to do. */
/* ---------------------------------------------------------- */
/* ---------------------------------------------------------- */
/* Set up pointers. */
/* ---------------------------------------------------------- */
/*io_ptr = data[block_no][0]+64-8; */
i=0;
for (j = 0; j < 8; j++)
{
/* ---------------------------------------------------- */
/* Load the freq-domain coefficients. */
/* ---------------------------------------------------- */
X0 = io_ptr[i];
X1 = io_ptr[1+i];
X2 = io_ptr[2+i];
X3 = io_ptr[3+i];
X4 = io_ptr[4+i];
X5 = io_ptr[5+i];
X6 = io_ptr[6+i];
X7 = io_ptr[7+i];
/* ---------------------------------------------------- */
/* Even part of decomp. Add rounding to DC term. */
/* ---------------------------------------------------- */
P0 = (((int)X0) << c4_shift) + round1;
P1 = (((int)X4) << c4_shift);
p0 = P0 + P1;
p1 = P0 - P1;
r1 = X2*c6 - X6*c2;
r0 = X2*c2 + X6*c6;
g0 = p0 + r0;
g1 = p1 + r1;
h1 = p1 - r1;
h0 = p0 - r0;
/* ---------------------------------------------------- */
/* Odd part of decomp. */
/* ---------------------------------------------------- */
g2 = (X1*c7 - X3*c5) + (X5*c3 - X7*c1);
g3 = (X1*c5 - X3*c1) + (X5*c7 + X7*c3);
h3 = (X1*c3 - X3*c7) - (X5*c1 + X7*c5);
h2 = (X1*c1 + X3*c3) + (X5*c5 + X7*c7);
/* ---------------------------------------------------- */
/* Final butterfly. */
/* ---------------------------------------------------- */
x0 = g0 + h2;
x1 = g1 + h3;
x2 = h1 + g3;
x3 = h0 + g2;
x4 = h0 - g2;
x5 = h1 - g3;
x6 = g1 - h3;
x7 = g0 - h2;
/* ---------------------------------------------------- */
/* Truncate to fit back into 16 bits. */
/* ---------------------------------------------------- */
x0t = x0 >> trunc1;
x1t = x1 >> trunc1;
x2t = x2 >> trunc1;
x3t = x3 >> trunc1;
x4t = x4 >> trunc1;
x5t = x5 >> trunc1;
x6t = x6 >> trunc1;
x7t = x7 >> trunc1;
/* ---------------------------------------------------- */
/* Store the results transposed. */
/* ---------------------------------------------------- */
io_ptr[i] = x0t;
io_ptr[1+i] =
cpp.rar_DCT变换_dct_dct cpp
版权申诉
95 浏览量
2022-09-20
14:55:01
上传
评论
收藏 4KB RAR 举报
邓凌佳
- 粉丝: 65
- 资源: 1万+