3 {$N+}
4 { This file contains a floating-point implementation of the
5 forward DCT (Discrete Cosine Transform).
7 This implementation should be more accurate than either of the integer
8 DCT implementations. However, it may not give the same results on all
9 machines because of differences in roundoff behavior. Speed will depend
10 on the hardware's floating point capacity.
12 A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
13 on each column. Direct algorithms are also available, but they are
14 much more complex and seem not to be any faster when reduced to code.
16 This implementation is based on Arai, Agui, and Nakajima's algorithm for
17 scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
18 Japanese, but the algorithm is described in the Pennebaker & Mitchell
19 JPEG textbook (see REFERENCES section in file README). The following code
20 is based directly on figure 4-8 in P&M.
21 While an 8-point DCT cannot be done in less than 11 multiplies, it is
22 possible to arrange the computation so that many of the multiplies are
23 simple scalings of the final outputs. These multiplies can then be
24 folded into the multiplications or divisions by the JPEG quantization
25 table entries. The AA&N method leaves only 5 multiplies and 29 adds
26 to be done in the DCT itself.
27 The primary disadvantage of this method is that with a fixed-point
28 implementation, accuracy is lost due to imprecise representation of the
29 scaled quantization values. However, that problem does not arise if
30 we use floating point arithmetic. }
32 { Original : jfdctflt.c ; Copyright (C) 1994-1996, Thomas G. Lane. }
34 interface
36 {$I imjconfig.inc}
38 uses
39 imjmorecfg,
40 imjinclude,
41 imjpeglib,
45 { Perform the forward DCT on one block of samples.}
47 {GLOBAL}
50 implementation
52 { This module is specialized to the case DCTSIZE = 8. }
54 {$ifndef DCTSIZE_IS_8}
56 {$endif}
59 { Perform the forward DCT on one block of samples.}
61 {GLOBAL}
63 type
66 var
72 begin
73 { Pass 1: process rows. }
77 begin
87 { Even part }
101 { Odd part }
107 { The rotator is modified from fig 4-8 to avoid extra negations. }
124 { Pass 2: process columns. }
128 begin
138 { Even part }
152 { Odd part }
158 { The rotator is modified from fig 4-8 to avoid extra negations. }