1 /* Reference_IDCT.c, Inverse Discrete Fourier Transform, double precision */
3 /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
6 * Disclaimer of Warranty
8 * These software programs are available to the user without any license fee or
9 * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims
10 * any and all warranties, whether express, implied, or statuary, including any
11 * implied warranties or merchantability or of fitness for a particular
12 * purpose. In no event shall the copyright-holder be liable for any
13 * incidental, punitive, or consequential damages of any kind whatsoever
14 * arising from the use of these programs.
16 * This disclaimer of warranty extends to the user of these programs and user's
17 * customers, employees, agents, transferees, successors, and assigns.
19 * The MPEG Software Simulation Group does not represent or warrant that the
20 * programs furnished hereunder are free of infringement of any third-party
23 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24 * are subject to royalty fees to patent holders. Many of these patents are
25 * general enough such that they are unavoidable regardless of implementation
30 /* Perform IEEE 1180 reference (64-bit floating point, separable 8x1
31 * direct matrix multiply) Inverse Discrete Cosine Transform
35 /* Here we use math.h to generate constants. Compiler results may
46 # define PI 3.14159265358979323846
50 /* global declarations */
51 void Initialize_Fast_IDCTref _ANSI_ARGS_((void));
52 void Reference_IDCT _ANSI_ARGS_((short *block));
56 /* cosine transform matrix for 8x1 IDCT */
57 static double c[8][8];
59 /* initialize DCT coefficient matrix */
61 void Initialize_Reference_IDCT()
66 for (freq=0; freq < 8; freq++)
68 scale = (freq == 0) ? sqrt(0.125) : 0.5;
69 for (time=0; time<8; time++)
70 c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
74 /* perform IDCT matrix multiply for 8x8 coefficient block */
76 void Reference_IDCT(block)
80 double partial_product;
86 partial_product = 0.0;
89 partial_product+= c[k][j]*block[8*i+k];
91 tmp[8*i+j] = partial_product;
94 /* Transpose operation is integrated into address mapping by switching
95 loop order of i and j */
100 partial_product = 0.0;
103 partial_product+= c[k][i]*tmp[8*k+j];
105 v = (int) floor(partial_product+0.5);
106 block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);