⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inverse discrete cosine transform.txt

📁 c6000的应用程序比较常用比如说fft ifft等一些原文件
💻 TXT
📖 第 1 页 / 共 5 页
字号:
* ========================================================================= *
*   NAME                                                                    *
*       idct_8x8 -- IEEE-1180 Compliant IDCT, Little Endian.                *
*                                                                           *
*   REVISION HISTORY                                                        *
*       30-Apr-1999 Reduce codesize                                         *
*       11-May-1999 New release version                                     *
*                                                                           *
*   USAGE                                                                   *
*       This routine is C callable, and has the following C prototype:      *
*                                                                           *
*           void idct_8x8(short idct_data[], unsigned num_idcts)            *
*                                                                           *
*       The idct_8x8 routine accepts a list of 8x8 DCT coeffient blocks     *
*       and performs IDCTs on each.  The array should be aligned to a       *
*       32-bit boundary, and be laid out equivalently to the C array        *
*       idct_data[num_idcts+1][8][8].                                       *
*                                                                           *
*       The routine requires one 8x8-block's worth of extra storage at      *
*       the end of the list of DCT blocks.  When processing 'num_idcts'     *
*       blocks, an area of length 'num_idcts + 1' must be provided.  The    *
*       contents of the extra block are ignored and overwritten with        *
*       intermediate results by idct_8x8().                                 *
*                                                                           *
*       This code requires '62 + 168 * num_idcts' cycles to process         *
*       'num_idcts' blocks, including 6 cycles of function call overhead.   *
*       When 'num_idcts' is zero, an early exit is taken and the function   *
*       runs for only 35 cycles (again, including overhead).                *
*                                                                           *
*   DESCRIPTION                                                             *
*       The idct_8x8 algorithm performs an IEEE-1180 compliant IDCT,        *
*       complete with rounding and saturation to signed 9-bit quantities.   *
*       The input coefficients are assumed to be signed 12-bit cosine       *
*       terms.                                                              *
*                                                                           *
*       void idct_8x8(short *idct_data, unsigned num_dcts)                  *
*       {                                                                   *
*         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;                              *
*         const short *i_ptr;                                               *
*         short       *o_ptr;                                               *
*         unsigned    i, j;                                                 *
*         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.  */  *
*         /* ---------------------------------------------------------- */  *
*         if (!num_dcts) return;                                            *
*                                                                           *
*         /* ---------------------------------------------------------- */  *
*         /*  Set up pointers.                                          */  *
*         /* ---------------------------------------------------------- */  *
*         i_ptr = idct_data + num_dcts * 64 - 8;                            *
*         o_ptr = idct_data + num_dcts * 64 + 7;                            *
*                                                                           *
*         for (j = 0; j < num_dcts; j++)                                    *
*         {                                                                 *
*           /* -------------------------------------------------------- */  *
*           /*  Perform Horizontal 1-D IDCT on each 8x8 block.  Store   */  *
*           /*  out the results transposed.                             */  *
*           /* -------------------------------------------------------- */  *
*           for (i = 0; i < 8; i++)                                         *
*           {                                                               *
*               /* ---------------------------------------------------- */  *
*               /*  Load the freq-domain coefficients.                  */  *
*               /* ---------------------------------------------------- */  *
*               X0 = i_ptr[0];                                              *
*               X1 = i_ptr[1];                                              *
*               X2 = i_ptr[2];                                              *
*               X3 = i_ptr[3];                                              *
*               X4 = i_ptr[4];                                              *
*               X5 = i_ptr[5];                                              *
*               X6 = i_ptr[6];                                              *
*               X7 = i_ptr[7];                                              *
*                                                                           *
*               i_ptr -= 8;             /* decr pointer to next row     */  *
*                                                                           *
*               /* ---------------------------------------------------- */  *
*               /*  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.                       */  *
*               /* ---------------------------------------------------- */  *
*               o_ptr[ 0] = x0t;                                            *
*               o_ptr[ 8] = x1t;                                            *
*               o_ptr[16] = x2t;                                            *
*               o_ptr[24] = x3t;                                            *
*               o_ptr[32] = x4t;                                            *
*               o_ptr[40] = x5t;                                            *
*               o_ptr[48] = x6t;                                            *
*               o_ptr[56] = x7t;                                            *
*                                                                           *
*               o_ptr--;                /* decrement ptr to next column */  *
*           }                                                               *
*                                                                           *
*           /* -------------------------------------------------------- */  *
*           /*  Update output pointer to point to next block.           */  *
*           /* -------------------------------------------------------- */  *
*                                                                           *
*           o_ptr = o_ptr + 8 - 64;                                         *
*         }                                                                 *
*                                                                           *
*         /* ---------------------------------------------------------- */  *
*         /*  Reset our pointers for the vertical pass.                 */  *
*         /* ---------------------------------------------------------- */  *
*         i_ptr = idct_data + 64;                                           *
*         o_ptr = idct_data;                                                *
*                                                                           *
*         for (j = 0; j < num_dcts; j++)                                    *
*         {                                                                 *
*           /* -------------------------------------------------------- */  *
*           /*  Perform Vertical 1-D IDCT on each 8x8 block.  Store     */  *
*           /*  out the results transposed.                             */  *
*           /* -------------------------------------------------------- */  *
*           for (i = 0; i < 8; i++)                                         *
*           {                                                               *
*               /* ---------------------------------------------------- */  *
*               /*  Load the freq-domain coefficients.                  */  *
*               /* ---------------------------------------------------- */  *
*               X0 = i_ptr[0];                                              *
*               X1 = i_ptr[1];                                              *
*               X2 = i_ptr[2];                                              *
*               X3 = i_ptr[3];                                              *
*               X4 = i_ptr[4];                                              *
*               X5 = i_ptr[5];                                              *
*               X6 = i_ptr[6];                                              *
*               X7 = i_ptr[7];                                              *
*               i_ptr += 8;             /* increment ptr to next row    */  *
*                                                                           *
*               /* ---------------------------------------------------- */  *
*               /*  Even part of decomp.  Add rouding term to DC.       */  *
*               /* ---------------------------------------------------- */  *
*               P0 = (((int)X0) << c4_shift) + round2; /* c4 is a shift */  *
*               P1 = (((int)X4) << c4_shift);          /* c4 is a shift */  *
*                                                                           *
*               p0 = P0 + P1;                                               *
*               p1 = P0 - P1;                                               *
*                                                                           *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -