📄 img_idct_8x8.h
字号:
/* ======================================================================== */
/* TEXAS INSTRUMENTS, INC. */
/* */
/* IMGLIB DSP Image/Video Processing Library */
/* */
/* Release: Version 1.02 */
/* CVS Revision: 1.11 Thu Mar 14 14:05:55 2002 (UTC) */
/* Snapshot date: 18-Apr-2002 */
/* */
/* This library contains proprietary intellectual property of Texas */
/* Instruments, Inc. The library and its source code are protected by */
/* various copyrights, and portions may also be protected by patents or */
/* other legal protections. */
/* */
/* This software is licensed for use with Texas Instruments TMS320 */
/* family DSPs. This license was provided to you prior to installing */
/* the software. You may review this license by consulting the file */
/* TI_license.PDF which accompanies the files in this library. */
/* ------------------------------------------------------------------------ */
/* Copyright (C) 2002 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
/* ======================================================================== */
/* NAME */
/* IMG_idct_8x8 -- IEEE-1180 Compliant IDCT, Little Endian. */
/* */
/* */
/* REVISION DATE */
/* 27-Jul-1999 */
/* */
/* USAGE */
/* This routine is C callable, and has the following C prototype: */
/* */
/* void IMG_idct_8x8(short idct_data[], unsigned num_idcts) */
/* */
/* The IMG_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. The caller must provide room */
/* for 'num_idcts + 1' blocks of data in the idct_data[] array. */
/* The contents of the extra block are ignored and overwritten */
/* with intermediate results by IMG_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, the function takes an early exit and */
/* runs for only 35 cycles (again, including overhead). */
/* */
/* DESCRIPTION */
/* The IMG_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 IMG_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; */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -