summaryrefslogtreecommitdiffstats
path: root/baseline/source/cjpeg_transupp
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
commit386b7d3366f1359a265da207a9cafa3edf553b64 (patch)
treec76120c2c138faed822e4ae386be6ef22a738a78 /baseline/source/cjpeg_transupp
parent54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff)
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'baseline/source/cjpeg_transupp')
-rw-r--r--baseline/source/cjpeg_transupp/ChangeLog.txt36
-rw-r--r--baseline/source/cjpeg_transupp/README417
-rw-r--r--baseline/source/cjpeg_transupp/cjpeg_transupp.c718
-rw-r--r--baseline/source/cjpeg_transupp/jpeglib.h757
4 files changed, 1928 insertions, 0 deletions
diff --git a/baseline/source/cjpeg_transupp/ChangeLog.txt b/baseline/source/cjpeg_transupp/ChangeLog.txt
new file mode 100644
index 0000000..df4383c
--- /dev/null
+++ b/baseline/source/cjpeg_transupp/ChangeLog.txt
@@ -0,0 +1,36 @@
1File: cjpeg_transupp.c
2Original provenience: MediaBench II benchmark suite,
3 http://euler.slu.edu/~fritts/mediabench (mirror)
4
52015-11-03:
6- Removed original header comment, replaced by TACLeBench header.
7- Removed unnecessary preprocessor macros.
8- Removed unnecessary code parts, simplified header files and include
9 relationships.
10- Added prefix "cjpeg_transupp" to all global symbols.
11- Added explicit forward declarations of functions.
12- Replaced initialization code by TACLeBench-compliant initialization code.
13- Added new function cjpeg_transupp_return producing a checksum as return value.
14- Added new function cjpeg_transupp_main according to TACLeBench guidelines.
15 cjpeg_transupp_main is annotated as entry-point for timing analysis.
16- Applied code formatting according to the following rules
17 - Lines shall not be wider than 80 characters; whenever possible, appropriate
18 line breaks shall be inserted to keep lines below 80 characters
19 - Indentation is done using whitespaces only, no tabs. Code is indented by
20 two whitespaces
21 - Two empty lines are put between any two functions
22 - In non-empty lists or index expressions, opening '(' and '[' are followed by
23 one whitespace, closing ')' and ']' are preceded by one whitespace
24 - In comma- or colon-separated argument lists, one whitespace is put after
25 each comma/colon
26 - Names of functions and global variables all start with a benchmark-specific
27 prefix (here: bs_) followed by lowercase letter (e.g., bs_square)
28 - For pointer types, one whitespace is put before the '*'
29 - Operators within expressions shall be preceded and followed by one
30 whitespace
31 - Code of then- and else-parts of if-then-else statements shall be put in
32 separate lines, not in the same lines as the if-condition or the keyword
33 "else"
34 - Opening braces '{' denoting the beginning of code for some if-else or loop
35 body shall be put at the end of the same line where the keywords "if",
36 "else", "for", "while" etc. occur
diff --git a/baseline/source/cjpeg_transupp/README b/baseline/source/cjpeg_transupp/README
new file mode 100644
index 0000000..8dba954
--- /dev/null
+++ b/baseline/source/cjpeg_transupp/README
@@ -0,0 +1,417 @@
1The Independent JPEG Group's JPEG software
2==========================================
3
4README for release 6a of 7-Feb-96
5=================================
6
7This distribution contains the sixth public release of the Independent JPEG
8Group's free JPEG software. You are welcome to redistribute this software and
9to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
10
11Serious users of this software (particularly those incorporating it into
12larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to
13our electronic mailing list. Mailing list members are notified of updates
14and have a chance to participate in technical discussions, etc.
15
16This software is the work of Tom Lane, Philip Gladstone, Luis Ortiz, Jim
17Boucher, Lee Crocker, Julian Minguillon, George Phillips, Davide Rossi,
18Ge' Weijers, and other members of the Independent JPEG Group.
19
20IJG is not affiliated with the official ISO JPEG standards committee.
21
22
23DOCUMENTATION ROADMAP
24=====================
25
26This file contains the following sections:
27
28OVERVIEW General description of JPEG and the IJG software.
29LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
30REFERENCES Where to learn more about JPEG.
31ARCHIVE LOCATIONS Where to find newer versions of this software.
32RELATED SOFTWARE Other stuff you should get.
33FILE FORMAT WARS Software *not* to get.
34TO DO Plans for future IJG releases.
35
36Other documentation files in the distribution are:
37
38User documentation:
39 install.doc How to configure and install the IJG software.
40 usage.doc Usage instructions for cjpeg, djpeg, jpegtran,
41 rdjpgcom, and wrjpgcom.
42 *.1 Unix-style man pages for programs (same info as usage.doc).
43 wizard.doc Advanced usage instructions for JPEG wizards only.
44 change.log Version-to-version change highlights.
45Programmer and internal documentation:
46 libjpeg.doc How to use the JPEG library in your own programs.
47 example.c Sample code for calling the JPEG library.
48 structure.doc Overview of the JPEG library's internal structure.
49 filelist.doc Road map of IJG files.
50 coderules.doc Coding style rules --- please read if you contribute code.
51
52Please read at least the files install.doc and usage.doc. Useful information
53can also be found in the JPEG FAQ (Frequently Asked Questions) article. See
54ARCHIVE LOCATIONS below to find out where to obtain the FAQ article.
55
56If you want to understand how the JPEG code works, we suggest reading one or
57more of the REFERENCES, then looking at the documentation files (in roughly
58the order listed) before diving into the code.
59
60
61OVERVIEW
62========
63
64This package contains C software to implement JPEG image compression and
65decompression. JPEG (pronounced "jay-peg") is a standardized compression
66method for full-color and gray-scale images. JPEG is intended for compressing
67"real-world" scenes; line drawings, cartoons and other non-realistic images
68are not its strong suit. JPEG is lossy, meaning that the output image is not
69exactly identical to the input image. Hence you must not use JPEG if you
70have to have identical output bits. However, on typical photographic images,
71very good compression levels can be obtained with no visible change, and
72remarkably high compression levels are possible if you can tolerate a
73low-quality image. For more details, see the references, or just experiment
74with various compression settings.
75
76This software implements JPEG baseline, extended-sequential, and progressive
77compression processes. Provision is made for supporting all variants of these
78processes, although some uncommon parameter settings aren't implemented yet.
79For legal reasons, we are not distributing code for the arithmetic-coding
80variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting
81the hierarchical or lossless processes defined in the standard.
82
83We provide a set of library routines for reading and writing JPEG image files,
84plus two sample applications "cjpeg" and "djpeg", which use the library to
85perform conversion between JPEG and some other popular image file formats.
86The library is intended to be reused in other applications.
87
88In order to support file conversion and viewing software, we have included
89considerable functionality beyond the bare JPEG coding/decoding capability;
90for example, the color quantization modules are not strictly part of JPEG
91decoding, but they are essential for output to colormapped file formats or
92colormapped displays. These extra functions can be compiled out of the
93library if not required for a particular application. We have also included
94"jpegtran", a utility for lossless transcoding between different JPEG
95processes, and "rdjpgcom" and "wrjpgcom", two simple applications for
96inserting and extracting textual comments in JFIF files.
97
98The emphasis in designing this software has been on achieving portability and
99flexibility, while also making it fast enough to be useful. In particular,
100the software is not intended to be read as a tutorial on JPEG. (See the
101REFERENCES section for introductory material.) Rather, it is intended to
102be reliable, portable, industrial-strength code. We do not claim to have
103achieved that goal in every aspect of the software, but we strive for it.
104
105We welcome the use of this software as a component of commercial products.
106No royalty is required, but we do ask for an acknowledgement in product
107documentation, as described under LEGAL ISSUES.
108
109Lossless image transformation routines. These routines work on DCT coefficient
110arrays and thus do not require any lossy decompression or recompression of the
111image. Thanks to Guido Vollbeding for the initial design and code of this
112feature.
113
114Horizontal flipping is done in-place, using a single top-to-bottom pass through
115the virtual source array. It will thus be much the fastest option for images
116larger than main memory.
117
118The other routines require a set of destination virtual arrays, so they need
119twice as much memory as jpegtran normally does. The destination arrays are
120always written in normal scan order (top to bottom) because the virtual array
121manager expects this. The source arrays will be scanned in the corresponding
122order, which means multiple passes through the source arrays for most of the
123transforms. That could result in much thrashing if the image is larger than main
124memory.
125
126Some notes about the operating environment of the individual transform routines:
1271. Both the source and destination virtual arrays are allocated from the source
128 JPEG object, and therefore should be manipulated by calling the source's
129 memory manager.
1302. The destination's component count should be used. It may be smaller than the
131 source's when forcing to grayscale.
1323. Likewise the destination's sampling factors should be used. When forcing to
133 grayscale the destination's sampling factors will be all 1, and we may as
134 well take that as the effective iMCU size.
1354. When "trim" is in effect, the destination's dimensions will be the trimmed
136 values but the source's will be untrimmed.
1375. All the routines assume that the source and destination buffers are padded
138 out to a full iMCU boundary. This is true, although for the source buffer it
139 is an undocumented property of jdcoefct.c.
140Notes 2,3,4 boil down to this: generally we should use the destination's
141dimensions and ignore the source's.
142
143
144LEGAL ISSUES
145============
146
147In plain English:
148
1491. We don't promise that this software works. (But if you find any bugs,
150 please let us know!)
1512. You can use this software for whatever you want. You don't have to pay us.
1523. You may not pretend that you wrote this software. If you use it in a
153 program, you must acknowledge somewhere in your documentation that
154 you've used the IJG code.
155
156In legalese:
157
158The authors make NO WARRANTY or representation, either express or implied,
159with respect to this software, its quality, accuracy, merchantability, or
160fitness for a particular purpose. This software is provided "AS IS", and you,
161its user, assume the entire risk as to its quality and accuracy.
162
163This software is copyright (C) 1991-1996, Thomas G. Lane.
164All Rights Reserved except as specified below.
165
166Permission is hereby granted to use, copy, modify, and distribute this
167software (or portions thereof) for any purpose, without fee, subject to these
168conditions:
169(1) If any part of the source code for this software is distributed, then this
170README file must be included, with this copyright and no-warranty notice
171unaltered; and any additions, deletions, or changes to the original files
172must be clearly indicated in accompanying documentation.
173(2) If only executable code is distributed, then the accompanying
174documentation must state that "this software is based in part on the work of
175the Independent JPEG Group".
176(3) Permission for use of this software is granted only if the user accepts
177full responsibility for any undesirable consequences; the authors accept
178NO LIABILITY for damages of any kind.
179
180These conditions apply to any software derived from or based on the IJG code,
181not just to the unmodified library. If you use our work, you ought to
182acknowledge us.
183
184Permission is NOT granted for the use of any IJG author's name or company name
185in advertising or publicity relating to this software or products derived from
186it. This software may be referred to only as "the Independent JPEG Group's
187software".
188
189We specifically permit and encourage the use of this software as the basis of
190commercial products, provided that all warranty or liability claims are
191assumed by the product vendor.
192
193
194ansi2knr.c is included in this distribution by permission of L. Peter Deutsch,
195sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
196ansi2knr.c is NOT covered by the above copyright and conditions, but instead
197by the usual distribution terms of the Free Software Foundation; principally,
198that you must include source code if you redistribute it. (See the file
199ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part
200of any program generated from the IJG code, this does not limit you more than
201the foregoing paragraphs do.
202
203The configuration script "configure" was produced with GNU Autoconf. It
204is copyright by the Free Software Foundation but is freely distributable.
205
206It appears that the arithmetic coding option of the JPEG spec is covered by
207patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot
208legally be used without obtaining one or more licenses. For this reason,
209support for arithmetic coding has been removed from the free JPEG software.
210(Since arithmetic coding provides only a marginal gain over the unpatented
211Huffman mode, it is unlikely that very many implementations will support it.)
212So far as we are aware, there are no patent restrictions on the remaining
213code.
214
215WARNING: Unisys has begun to enforce their patent on LZW compression against
216GIF encoders and decoders. You will need a license from Unisys to use the
217included rdgif.c or wrgif.c files in a commercial or shareware application.
218At this time, Unisys is not enforcing their patent against freeware, so
219distribution of this package remains legal. However, we intend to remove
220GIF support from the IJG package as soon as a suitable replacement format
221becomes reasonably popular.
222
223We are required to state that
224 "The Graphics Interchange Format(c) is the Copyright property of
225 CompuServe Incorporated. GIF(sm) is a Service Mark property of
226 CompuServe Incorporated."
227
228
229REFERENCES
230==========
231
232We highly recommend reading one or more of these references before trying to
233understand the innards of the JPEG software.
234
235The best short technical introduction to the JPEG compression algorithm is
236 Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
237 Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
238(Adjacent articles in that issue discuss MPEG motion picture compression,
239applications of JPEG, and related topics.) If you don't have the CACM issue
240handy, a PostScript file containing a revised version of Wallace's article
241is available at ftp.uu.net, graphics/jpeg/wallace.ps.gz. The file (actually
242a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
243omits the sample images that appeared in CACM, but it includes corrections
244and some added material. Note: the Wallace article is copyright ACM and
245IEEE, and it may not be used for commercial purposes.
246
247A somewhat less technical, more leisurely introduction to JPEG can be found in
248"The Data Compression Book" by Mark Nelson, published by M&T Books (Redwood
249City, CA), 1991, ISBN 1-55851-216-0. This book provides good explanations and
250example C code for a multitude of compression methods including JPEG. It is
251an excellent source if you are comfortable reading C code but don't know much
252about data compression in general. The book's JPEG sample code is far from
253industrial-strength, but when you are ready to look at a full implementation,
254you've got one here...
255
256The best full description of JPEG is the textbook "JPEG Still Image Data
257Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published
258by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp.
259The book includes the complete text of the ISO JPEG standards (DIS 10918-1
260and draft DIS 10918-2). This is by far the most complete exposition of JPEG
261in existence, and we highly recommend it.
262
263The JPEG standard itself is not available electronically; you must order a
264paper copy through ISO or ITU. (Unless you feel a need to own a certified
265official copy, we recommend buying the Pennebaker and Mitchell book instead;
266it's much cheaper and includes a great deal of useful explanatory material.)
267In the USA, copies of the standard may be ordered from ANSI Sales at (212)
268642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI
269doesn't take credit card orders, but Global does.) It's not cheap: as of
2701992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7%
271shipping/handling. The standard is divided into two parts, Part 1 being the
272actual specification, while Part 2 covers compliance testing methods. Part 1
273is titled "Digital Compression and Coding of Continuous-tone Still Images,
274Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
27510918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
276Continuous-tone Still Images, Part 2: Compliance testing" and has document
277numbers ISO/IEC IS 10918-2, ITU-T T.83.
278
279Extensions to the original JPEG standard are defined in JPEG Part 3, a new ISO
280document. Part 3 is undergoing ISO balloting and is expected to be approved
281by the end of 1995; it will have document numbers ISO/IEC IS 10918-3, ITU-T
282T.84. IJG currently does not support any Part 3 extensions.
283
284The JPEG standard does not specify all details of an interchangeable file
285format. For the omitted details we follow the "JFIF" conventions, revision
2861.02. A copy of the JFIF spec is available from:
287 Literature Department
288 C-Cube Microsystems, Inc.
289 1778 McCarthy Blvd.
290 Milpitas, CA 95035
291 phone (408) 944-6300, fax (408) 944-6314
292A PostScript version of this document is available at ftp.uu.net, file
293graphics/jpeg/jfif.ps.gz. It can also be obtained by e-mail from the C-Cube
294mail server, netlib@c3.pla.ca.us. Send the message "send jfif_ps from jpeg"
295to the server to obtain the JFIF document; send the message "help" if you have
296trouble.
297
298The TIFF 6.0 file format specification can be obtained by FTP from sgi.com
299(192.48.153.1), file graphics/tiff/TIFF6.ps.Z; or you can order a printed
300copy from Aldus Corp. at (206) 628-6593. The JPEG incorporation scheme
301found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
302IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
303Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
304(Compression tag 7). Copies of this Note can be obtained from sgi.com or
305from ftp.uu.net:/graphics/jpeg/. It is expected that the next revision of
306the TIFF spec will replace the 6.0 JPEG design with the Note's design.
307Although IJG's own code does not support TIFF/JPEG, the free libtiff library
308uses our library to implement TIFF/JPEG per the Note. libtiff is available
309from sgi.com:/graphics/tiff/.
310
311
312ARCHIVE LOCATIONS
313=================
314
315The "official" archive site for this software is ftp.uu.net (Internet
316address 192.48.96.9). The most recent released version can always be found
317there in directory graphics/jpeg. This particular version will be archived
318as graphics/jpeg/jpegsrc.v6a.tar.gz. If you are on the Internet, you
319can retrieve files from ftp.uu.net by standard anonymous FTP. If you don't
320have FTP access, UUNET's archives are also available via UUCP; contact
321help@uunet.uu.net for information on retrieving files that way.
322
323Numerous Internet sites maintain copies of the UUNET files. However, only
324ftp.uu.net is guaranteed to have the latest official version.
325
326You can also obtain this software in DOS-compatible "zip" archive format from
327the SimTel archives (ftp.coast.net:/SimTel/msdos/graphics/), or on CompuServe
328in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 "JPEG Tools".
329Again, these versions may sometimes lag behind the ftp.uu.net release.
330
331The JPEG FAQ (Frequently Asked Questions) article is a useful source of
332general information about JPEG. It is updated constantly and therefore is
333not included in this distribution. The FAQ is posted every two weeks to
334Usenet newsgroups comp.graphics.misc, news.answers, and other groups.
335You can always obtain the latest version from the news.answers archive at
336rtfm.mit.edu. By FTP, fetch /pub/usenet/news.answers/jpeg-faq/part1 and
337.../part2. If you don't have FTP, send e-mail to mail-server@rtfm.mit.edu
338with body
339 send usenet/news.answers/jpeg-faq/part1
340 send usenet/news.answers/jpeg-faq/part2
341
342
343RELATED SOFTWARE
344================
345
346Numerous viewing and image manipulation programs now support JPEG. (Quite a
347few of them use this library to do so.) The JPEG FAQ described above lists
348some of the more popular free and shareware viewers, and tells where to
349obtain them on Internet.
350
351If you are on a Unix machine, we highly recommend Jef Poskanzer's free
352PBMPLUS image software, which provides many useful operations on PPM-format
353image files. In particular, it can convert PPM images to and from a wide
354range of other formats. You can obtain this package by FTP from ftp.x.org
355(contrib/pbmplus*.tar.Z) or ftp.ee.lbl.gov (pbmplus*.tar.Z). There is also
356a newer update of this package called NETPBM, available from
357wuarchive.wustl.edu under directory /graphics/graphics/packages/NetPBM/.
358Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software
359is; you are likely to have difficulty making it work on any non-Unix machine.
360
361A different free JPEG implementation, written by the PVRG group at Stanford,
362is available from havefun.stanford.edu in directory pub/jpeg. This program
363is designed for research and experimentation rather than production use;
364it is slower, harder to use, and less portable than the IJG code, but it
365is easier to read and modify. Also, the PVRG code supports lossless JPEG,
366which we do not.
367
368
369FILE FORMAT WARS
370================
371
372Some JPEG programs produce files that are not compatible with our library.
373The root of the problem is that the ISO JPEG committee failed to specify a
374concrete file format. Some vendors "filled in the blanks" on their own,
375creating proprietary formats that no one else could read. (For example, none
376of the early commercial JPEG implementations for the Macintosh were able to
377exchange compressed files.)
378
379The file format we have adopted is called JFIF (see REFERENCES). This format
380has been agreed to by a number of major commercial JPEG vendors, and it has
381become the de facto standard. JFIF is a minimal or "low end" representation.
382We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF
383Technical Note #2) for "high end" applications that need to record a lot of
384additional data about an image. TIFF/JPEG is fairly new and not yet widely
385supported, unfortunately.
386
387The upcoming JPEG Part 3 standard defines a file format called SPIFF.
388SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should
389be able to read the most common variant of SPIFF. SPIFF has some technical
390advantages over JFIF, but its major claim to fame is simply that it is an
391official standard rather than an informal one. At this point it is unclear
392whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto
393standard. IJG intends to support SPIFF once the standard is frozen, but we
394have not decided whether it should become our default output format or not.
395(In any case, our decoder will remain capable of reading JFIF indefinitely.)
396
397Various proprietary file formats incorporating JPEG compression also exist.
398We have little or no sympathy for the existence of these formats. Indeed,
399one of the original reasons for developing this free software was to help
400force convergence on common, open format standards for JPEG files. Don't
401use a proprietary file format!
402
403
404TO DO
405=====
406
407In future versions, we are considering supporting some of the upcoming JPEG
408Part 3 extensions --- principally, variable quantization and the SPIFF file
409format.
410
411Tuning the software for better behavior at low quality/high compression
412settings is also of interest. The current method for scaling the
413quantization tables is known not to be very good at low Q values.
414
415As always, speeding things up is high on our priority list.
416
417Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.
diff --git a/baseline/source/cjpeg_transupp/cjpeg_transupp.c b/baseline/source/cjpeg_transupp/cjpeg_transupp.c
new file mode 100644
index 0000000..e77d15b
--- /dev/null
+++ b/baseline/source/cjpeg_transupp/cjpeg_transupp.c
@@ -0,0 +1,718 @@
1/*
2
3 This program is part of the TACLeBench benchmark suite.
4 Version V 2.0
5
6 Name: cjpeg_transupp
7
8 Author: Thomas G. Lane
9
10 Function: This file contains image transformation routines and other utility
11 code used by the jpegtran sample application. These are NOT part of the core
12 JPEG library. But we keep these routines separate from jpegtran.c to ease
13 the task of maintaining jpegtran-like programs that have other user
14 interfaces.
15
16 Source: MediaBench II
17 http://euler.slu.edu/~fritts/mediabench (mirror)
18
19 Original name: cjpeg
20
21 Changes: No major functional changes.
22
23 License: See the accompanying README file.
24
25*/
26
27
28/*
29 Include section
30*/
31
32#include "../extra.h"
33#include "jpeglib.h"
34
35
36/*
37 Forward declaration of functions
38*/
39
40void cjpeg_transupp_initSeed( void );
41signed char cjpeg_transupp_randomInteger( void );
42void cjpeg_transupp_init( void );
43int cjpeg_transupp_return( void );
44void cjpeg_transupp_do_flip_v( j_compress_ptr );
45void cjpeg_transupp_do_rot_90( j_compress_ptr );
46void cjpeg_transupp_do_rot_180( j_compress_ptr );
47void cjpeg_transupp_do_rot_270( j_compress_ptr );
48void cjpeg_transupp_do_transverse( j_compress_ptr );
49void cjpeg_transupp_main( void );
50//int main( void );
51
52
53/*
54 Declaration of global variables
55*/
56
57volatile int cjpeg_transupp_seed;
58
59signed char cjpeg_transupp_input[ 256 ];
60signed char cjpeg_transupp_input2[ 80 ];
61signed char cjpeg_transupp_input3[ 65 ];
62signed char cjpeg_transupp_input3_2[ 65 ];
63signed char cjpeg_transupp_input4[ 64 ];
64signed char cjpeg_transupp_input5[ 65 ];
65signed char cjpeg_transupp_input5_2[ 65 ];
66
67/* Output arrays replace writing of results into a file. */
68signed char cjpeg_transupp_output_data[ 512 ];
69signed char cjpeg_transupp_output_data2[ 512 ];
70signed char cjpeg_transupp_output_data3[ 512 ];
71signed char cjpeg_transupp_output_data4[ 512 ];
72signed char cjpeg_transupp_output_data5[ 512 ];
73
74struct jpeg_compress_struct cjpeg_transupp_dstinfo;
75
76
77/*
78 Initialization- and return-value-related functions
79*/
80
81void cjpeg_transupp_initSeed( void )
82{
83 cjpeg_transupp_seed = 0;
84}
85
86
87/*
88 cjpeg_transupp_RandomInteger generates random integers between -128 and 127.
89*/
90signed char cjpeg_transupp_randomInteger( void )
91{
92 cjpeg_transupp_seed = ( ( ( cjpeg_transupp_seed * 133 ) + 81 ) % 256 ) - 128;
93 return( cjpeg_transupp_seed );
94}
95
96
97void cjpeg_transupp_init( void )
98{
99 register int i;
100
101
102 cjpeg_transupp_dstinfo.max_h_samp_factor = 2;
103 cjpeg_transupp_dstinfo.max_v_samp_factor = 2;
104 cjpeg_transupp_dstinfo.num_components = 3;
105
106 cjpeg_transupp_initSeed();
107
108 _Pragma( "loopbound min 256 max 256" )
109 for ( i = 0; i < 256; i++ )
110 cjpeg_transupp_input[ i ] = cjpeg_transupp_randomInteger();
111
112 _Pragma( "loopbound min 80 max 80" )
113 for ( i = 0; i < 80; i++ )
114 cjpeg_transupp_input2[ i ] = cjpeg_transupp_randomInteger();
115
116 _Pragma( "loopbound min 65 max 65" )
117 for ( i = 0; i < 65; i++ )
118 cjpeg_transupp_input3[ i ] = cjpeg_transupp_randomInteger();
119
120 _Pragma( "loopbound min 65 max 65" )
121 for ( i = 0; i < 65; i++ )
122 cjpeg_transupp_input3_2[ i ] = cjpeg_transupp_randomInteger();
123
124 _Pragma( "loopbound min 64 max 64" )
125 for ( i = 0; i < 64; i++ )
126 cjpeg_transupp_input4[ i ] = cjpeg_transupp_randomInteger();
127
128 _Pragma( "loopbound min 65 max 65" )
129 for ( i = 0; i < 65; i++ )
130 cjpeg_transupp_input5[ i ] = cjpeg_transupp_randomInteger();
131
132 _Pragma( "loopbound min 65 max 65" )
133 for ( i = 0; i < 65; i++ )
134 cjpeg_transupp_input5_2[ i ] = cjpeg_transupp_randomInteger();
135}
136
137
138int cjpeg_transupp_return( void )
139{
140 int checksum = 0;
141 unsigned int i;
142
143
144 _Pragma( "loopbound min 512 max 512" )
145 for ( i = 0; i < 512; i++ )
146 checksum += cjpeg_transupp_output_data[ i ];
147
148 _Pragma( "loopbound min 512 max 512" )
149 for ( i = 0; i < 512; i++ )
150 checksum += cjpeg_transupp_output_data2[ i ];
151
152 _Pragma( "loopbound min 512 max 512" )
153 for ( i = 0; i < 512; i++ )
154 checksum += cjpeg_transupp_output_data3[ i ];
155
156 _Pragma( "loopbound min 512 max 512" )
157 for ( i = 0; i < 512; i++ )
158 checksum += cjpeg_transupp_output_data4[ i ];
159
160 _Pragma( "loopbound min 512 max 512" )
161 for ( i = 0; i < 512; i++ )
162 checksum += cjpeg_transupp_output_data5[ i ];
163
164 return( checksum );
165}
166
167
168/*
169 Algorithm core functions
170*/
171
172/*
173 Vertical flip
174*/
175void cjpeg_transupp_do_flip_v( j_compress_ptr dstinfo )
176{
177 unsigned int MCU_rows, comp_height, dst_blk_x, dst_blk_y;
178 int ci, i, j, offset_y;
179 JCOEFPTR src_ptr, dst_ptr;
180
181
182 /*
183 We output into a separate array because we can't touch different rows of the
184 source virtual array simultaneously. Otherwise, this is a pretty
185 straightforward analog of horizontal flip.
186 Within a DCT block, vertical mirroring is done by changing the signs of
187 odd-numbered rows.
188 Partial iMCUs at the bottom edge are copied verbatim.
189 */
190 MCU_rows = dstinfo->image_height / ( dstinfo->max_v_samp_factor * DCTSIZE );
191
192 int compptr_v_samp_factor = 8;
193 unsigned int compptr_height_in_blocks = 19;
194 unsigned int compptr_width_in_blocks = 29;
195
196 _Pragma( "loopbound min 3 max 3" )
197 for ( ci = 0; ci < dstinfo->num_components;
198 ci++, compptr_v_samp_factor = 1, compptr_width_in_blocks = 15 ) {
199 comp_height = MCU_rows * compptr_v_samp_factor;
200
201 compptr_height_in_blocks = 10;
202 _Pragma( "loopbound min 2 max 10" )
203 for ( dst_blk_y = 0; dst_blk_y < compptr_height_in_blocks;
204 dst_blk_y += compptr_v_samp_factor ) {
205
206 _Pragma( "loopbound min 1 max 8" )
207 for ( offset_y = 0; offset_y < compptr_v_samp_factor; offset_y++ ) {
208 if ( dst_blk_y < comp_height ) {
209
210 /* Row is within the mirrorable area. */
211 _Pragma( "loopbound min 15 max 29" )
212 for ( dst_blk_x = 0; dst_blk_x < compptr_width_in_blocks;
213 dst_blk_x++ ) {
214
215 src_ptr = cjpeg_transupp_input;
216 dst_ptr = cjpeg_transupp_output_data;
217
218 _Pragma( "loopbound min 4 max 4" )
219 for ( i = 0; i < DCTSIZE; i += 2 ) {
220
221 /* copy even row */
222 j = 0;
223 _Pragma( "loopbound min 8 max 8" )
224 do {
225 if ( dst_blk_x < comp_height )
226 *dst_ptr++ = *src_ptr++;
227 j++;
228 } while ( j < DCTSIZE );
229
230 /* copy odd row with sign change */
231 j = 0;
232 _Pragma( "loopbound min 8 max 8" )
233 do {
234 if ( dst_blk_x < comp_height )
235 *dst_ptr++ = - *src_ptr++;
236 j++;
237 } while ( j < DCTSIZE );
238 }
239 }
240 }
241 }
242 }
243 }
244}
245
246
247/*
248 90 degree rotation is equivalent to
249 1. Transposing the image;
250 2. Horizontal mirroring.
251 These two steps are merged into a single processing routine.
252*/
253void cjpeg_transupp_do_rot_90( j_compress_ptr dstinfo )
254{
255 unsigned int MCU_cols, comp_width, dst_blk_x, dst_blk_y;
256 int ci, i, j, offset_x, offset_y;
257 JCOEFPTR src_ptr, dst_ptr;
258
259
260 /*
261 Because of the horizontal mirror step, we can't process partial iMCUs at the
262 (output) right edge properly. They just get transposed and not mirrored.
263 */
264 MCU_cols = dstinfo->image_width / ( dstinfo->max_h_samp_factor * DCTSIZE );
265
266 int compptr_h_samp_factor = 2;
267 int compptr_v_samp_factor = 8;
268 unsigned int compptr_height_in_blocks = 29;
269 unsigned int compptr_width_in_blocks = 19;
270
271
272 _Pragma( "loopbound min 3 max 3" )
273 for ( ci = 0; ci < dstinfo->num_components;
274 ci++, compptr_h_samp_factor = compptr_v_samp_factor = 1,
275 compptr_height_in_blocks = 15, compptr_width_in_blocks = 10 ) {
276
277 comp_width = MCU_cols * compptr_h_samp_factor;
278
279 _Pragma( "loopbound min 4 max 15" )
280 for ( dst_blk_y = 0; dst_blk_y < compptr_height_in_blocks;
281 dst_blk_y += compptr_v_samp_factor ) {
282
283 offset_y = 0;
284 _Pragma( "loopbound min 1 max 8" )
285 for ( ; offset_y < compptr_v_samp_factor; offset_y++ ) {
286 dst_blk_x = 0;
287 _Pragma( "loopbound min 10 max 10" )
288 for ( ; dst_blk_x < compptr_width_in_blocks;
289 dst_blk_x += compptr_h_samp_factor ) {
290
291 offset_x = 0;
292 _Pragma( "loopbound min 1 max 2" )
293 for ( ; offset_x < compptr_h_samp_factor; offset_x++ ) {
294
295 src_ptr = cjpeg_transupp_input2;
296
297 if ( dst_blk_x < comp_width ) {
298
299 /* Block is within the mirrorable area. */
300 dst_ptr = cjpeg_transupp_output_data2;
301
302 _Pragma( "loopbound min 4 max 4" )
303 for ( i = 0; i < DCTSIZE; i++ ) {
304 j = 0;
305 _Pragma( "loopbound min 8 max 8" )
306 for ( ; j < DCTSIZE; j++ )
307 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
308
309 i++;
310
311 _Pragma( "loopbound min 8 max 8" )
312 for ( j = 0; j < DCTSIZE; j++ )
313 dst_ptr[ j * DCTSIZE + i ] = -src_ptr[ i * DCTSIZE + j ];
314 }
315 } else {
316 /* Edge blocks are transposed but not mirrored. */
317 dst_ptr = cjpeg_transupp_output_data2;
318
319 _Pragma( "loopbound min 8 max 8" )
320 for ( i = 0; i < DCTSIZE; i++ )
321 j = 0;
322 _Pragma( "loopbound min 8 max 8" )
323 for ( ; j < DCTSIZE; j++ ) {
324 if ( dst_blk_y < comp_width )
325 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
326 }
327 }
328 }
329 }
330 }
331 }
332 }
333}
334
335
336/*
337 270 degree rotation is equivalent to
338 1. Horizontal mirroring;
339 2. Transposing the image.
340 These two steps are merged into a single processing routine.
341*/
342void cjpeg_transupp_do_rot_270( j_compress_ptr dstinfo )
343{
344 unsigned int MCU_rows, comp_height, dst_blk_x, dst_blk_y;
345 int ci, i, j, offset_x, offset_y;
346 JCOEFPTR src_ptr, dst_ptr;
347
348
349 /*
350 Because of the horizontal mirror step, we can't process partial iMCUs at the
351 (output) bottom edge properly. They just get transposed and not mirrored.
352 */
353 MCU_rows = dstinfo->image_height / ( dstinfo->max_v_samp_factor * DCTSIZE );
354
355 int compptr_h_samp_factor = 2;
356 int compptr_v_samp_factor = 8;
357 unsigned int compptr_height_in_blocks = 29;
358 unsigned int compptr_width_in_blocks = 19;
359
360 _Pragma( "loopbound min 3 max 3" )
361 for ( ci = 0; ci < dstinfo->num_components;
362 ci++, compptr_h_samp_factor = compptr_v_samp_factor = 1,
363 compptr_height_in_blocks = 15, compptr_width_in_blocks = 10 ) {
364
365 comp_height = MCU_rows * compptr_v_samp_factor;
366
367 _Pragma( "loopbound min 4 max 15" )
368 for ( dst_blk_y = 0; dst_blk_y < compptr_height_in_blocks;
369 dst_blk_y += compptr_v_samp_factor ) {
370
371 offset_y = 0;
372 _Pragma( "loopbound min 1 max 8" )
373 for ( ; offset_y < compptr_v_samp_factor; offset_y++ ) {
374 dst_blk_x = 0;
375 _Pragma( "loopbound min 10 max 10" )
376 for ( ; dst_blk_x < compptr_width_in_blocks;
377 dst_blk_x += compptr_h_samp_factor ) {
378
379 offset_x = 0;
380 _Pragma( "loopbound min 1 max 2" )
381 for ( ; offset_x < compptr_h_samp_factor; offset_x++ ) {
382
383 dst_ptr = cjpeg_transupp_output_data3;
384
385 if ( dst_blk_y < comp_height ) {
386
387 /* Block is within the mirrorable area. */
388 src_ptr = cjpeg_transupp_input3;
389
390 _Pragma( "loopbound min 8 max 8" )
391 for ( i = 0; i < DCTSIZE; i++ ) {
392 j = 0;
393 _Pragma( "loopbound min 4 max 4" )
394 for ( ; j < DCTSIZE; j++ ) {
395 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
396 j++;
397 dst_ptr[ j * DCTSIZE + i ] = -src_ptr[ i * DCTSIZE + j ];
398 }
399 }
400 } else {
401
402 /* Edge blocks are transposed but not mirrored. */
403 src_ptr = cjpeg_transupp_input3_2;
404
405 _Pragma( "loopbound min 8 max 8" )
406 for ( i = 0; i < DCTSIZE; i++ )
407 j = 0;
408 _Pragma( "loopbound min 8 max 8" )
409 for ( ; j < DCTSIZE; j++ ) {
410 if ( dst_blk_y < comp_height )
411 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
412 }
413 }
414 }
415 }
416 }
417 }
418 }
419}
420
421
422/*
423 180 degree rotation is equivalent to
424 1. Vertical mirroring;
425 2. Horizontal mirroring.
426 These two steps are merged into a single processing routine.
427*/
428void cjpeg_transupp_do_rot_180( j_compress_ptr dstinfo )
429{
430 unsigned int MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x,
431 dst_blk_y;
432 int ci, i, j, offset_y;
433 JCOEFPTR src_ptr, dst_ptr;
434
435 int compptr_h_samp_factor = 2;
436 int compptr_v_samp_factor = 8;
437 unsigned int compptr_width_in_blocks = 29;
438 unsigned int compptr_height_in_blocks = 19;
439
440
441 MCU_cols = dstinfo->image_width / ( dstinfo->max_h_samp_factor * DCTSIZE );
442 MCU_rows = dstinfo->image_height / ( dstinfo->max_v_samp_factor * DCTSIZE );
443
444 _Pragma( "loopbound min 3 max 3" )
445 for ( ci = 0; ci < dstinfo->num_components; ci++,
446 compptr_h_samp_factor = compptr_v_samp_factor = 1,
447 compptr_width_in_blocks = 15, compptr_height_in_blocks = 10 ) {
448
449 comp_width = MCU_cols * compptr_h_samp_factor;
450 comp_height = MCU_rows * compptr_v_samp_factor;
451
452 _Pragma( "loopbound min 3 max 10" )
453 for ( dst_blk_y = 0; dst_blk_y < compptr_height_in_blocks;
454 dst_blk_y += compptr_v_samp_factor ) {
455 offset_y = 0;
456 _Pragma( "loopbound min 1 max 8" )
457 for ( ; offset_y < compptr_v_samp_factor; offset_y++ ) {
458 if ( dst_blk_y < comp_height ) {
459
460 /* Row is within the mirrorable area. */
461
462 /* Process the blocks that can be mirrored both ways. */
463 _Pragma( "loopbound min 14 max 28" )
464 for ( dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++ ) {
465 dst_ptr = cjpeg_transupp_output_data4;
466 src_ptr = cjpeg_transupp_input4;
467
468 _Pragma( "loopbound min 4 max 4" )
469 for ( i = 0; i < DCTSIZE; i += 2 ) {
470 j = 0;
471 /* For even row, negate every odd column. */
472 _Pragma( "loopbound min 4 max 4" )
473 for ( ; j < DCTSIZE; j += 2 ) {
474 if ( dst_blk_x < comp_height ) {
475 *dst_ptr++ = *src_ptr++;
476 *dst_ptr++ = - *src_ptr++;
477 }
478 }
479
480 j = 0;
481 /* For odd row, negate every even column. */
482 _Pragma( "loopbound min 4 max 4" )
483 for ( ; j < DCTSIZE; j += 2 ) {
484 if ( dst_blk_x < comp_height ) {
485 *dst_ptr++ = - *src_ptr++;
486 *dst_ptr++ = *src_ptr++;
487 }
488 }
489 }
490 }
491
492 /* Any remaining right-edge blocks are only mirrored vertically. */
493 _Pragma( "loopbound min 1 max 1" )
494 for ( ; dst_blk_x < compptr_width_in_blocks; dst_blk_x++ ) {
495
496 dst_ptr = cjpeg_transupp_output_data4;
497 src_ptr = cjpeg_transupp_input4;
498 _Pragma( "loopbound min 4 max 4" )
499 for ( i = 0; i < DCTSIZE; i += 2 ) {
500 j = 0;
501 _Pragma( "loopbound min 8 max 8" )
502 for ( ; j < DCTSIZE; j++ )
503 *dst_ptr++ = *src_ptr++;
504 j = 0;
505 _Pragma( "loopbound min 8 max 8" )
506 for ( ; j < DCTSIZE; j++ )
507 *dst_ptr++ = - *src_ptr++;
508 }
509 }
510 } else {
511
512 /* Remaining rows are just mirrored horizontally. */
513 dst_blk_x = 0;
514 /* Process the blocks that can be mirrored. */
515 _Pragma( "loopbound min 14 max 28" )
516 do {
517 dst_ptr = cjpeg_transupp_output_data4;
518 src_ptr = cjpeg_transupp_input4;
519
520 i = 0;
521 _Pragma( "loopbound min 32 max 32" )
522 while ( i < DCTSIZE2 ) {
523 *dst_ptr++ = *src_ptr++;
524 *dst_ptr++ = - *src_ptr++;
525 i += 2;
526 dst_ptr += 0;
527 }
528 dst_blk_x++;
529 dst_ptr += 0;
530 } while ( dst_blk_x < comp_width );
531
532 /* Any remaining right-edge blocks are only copied. */
533 _Pragma( "loopbound min 1 max 1" )
534 for ( ; dst_blk_x < compptr_width_in_blocks; dst_blk_x++ ) {
535
536 dst_ptr = cjpeg_transupp_output_data4;
537 src_ptr = cjpeg_transupp_input4;
538 _Pragma( "loopbound min 64 max 64" )
539 do {
540 *dst_ptr++ = *src_ptr++;
541 i++;
542 } while ( i < DCTSIZE2 );
543 }
544 }
545 }
546 }
547 }
548}
549
550
551/*
552 Transverse transpose is equivalent to
553 1. 180 degree rotation;
554 2. Transposition;
555 or
556 1. Horizontal mirroring;
557 2. Transposition;
558 3. Horizontal mirroring.
559 These steps are merged into a single processing routine.
560*/
561void cjpeg_transupp_do_transverse( j_compress_ptr dstinfo )
562{
563 unsigned int MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x,
564 dst_blk_y;
565 int ci, i, j, offset_x, offset_y;
566 JCOEFPTR src_ptr, dst_ptr;
567
568 int compptr_h_samp_factor = 2;
569 int compptr_v_samp_factor = 8;
570 unsigned int compptr_height_in_blocks = 29;
571 unsigned int compptr_width_in_blocks = 19;
572
573
574 MCU_cols = dstinfo->image_width / ( dstinfo->max_h_samp_factor * DCTSIZE );
575 MCU_rows = dstinfo->image_height / ( dstinfo->max_v_samp_factor * DCTSIZE );
576
577 _Pragma( "loopbound min 3 max 3" )
578 for ( ci = 0; ci < dstinfo->num_components; ci++,
579 compptr_h_samp_factor = compptr_v_samp_factor = 1,
580 compptr_height_in_blocks = 15, compptr_width_in_blocks = 10 ) {
581
582 comp_width = MCU_cols * compptr_h_samp_factor;
583 comp_height = MCU_rows * compptr_v_samp_factor;
584
585 _Pragma( "loopbound min 4 max 15" )
586 for ( dst_blk_y = 0; dst_blk_y < compptr_height_in_blocks;
587 dst_blk_y += compptr_v_samp_factor ) {
588 offset_y = 0;
589 _Pragma( "loopbound min 1 max 8" )
590 do {
591 dst_blk_x = 0;
592 _Pragma( "loopbound min 10 max 10" )
593 do {
594 offset_x = 0;
595 _Pragma( "loopbound min 1 max 2" )
596 for ( ; offset_x < compptr_h_samp_factor; offset_x++ ) {
597
598 if ( dst_blk_y < comp_height ) {
599 src_ptr = cjpeg_transupp_input5;
600
601 if ( dst_blk_x < comp_width ) {
602 /* Block is within the mirrorable area. */
603 dst_ptr = cjpeg_transupp_output_data5;
604
605 _Pragma( "loopbound min 4 max 4" )
606 for ( i = 0; i < DCTSIZE; i++ ) {
607 j = 0;
608 _Pragma( "loopbound min 4 max 4" )
609 for ( ; j < DCTSIZE; j++ ) {
610 if ( dst_blk_y < comp_width )
611 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
612 j++;
613 dst_ptr[ j * DCTSIZE + i ] = -src_ptr[ i * DCTSIZE + j ];
614 }
615 i++;
616 _Pragma( "loopbound min 4 max 4" )
617 for ( j = 0; j < DCTSIZE; j++ ) {
618 if ( dst_blk_y < comp_width )
619 dst_ptr[ j * DCTSIZE + i ] = -src_ptr[ i * DCTSIZE + j ];
620 j++;
621 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
622 }
623 }
624 } else {
625 /* Right-edge blocks are mirrored in y only */
626 dst_ptr = cjpeg_transupp_output_data5;
627 _Pragma( "loopbound min 8 max 8" )
628 for ( i = 0; i < DCTSIZE; i++ ) {
629 j = 0;
630 _Pragma( "loopbound min 4 max 4" )
631 for ( ; j < DCTSIZE; j++ ) {
632 if ( dst_blk_y < comp_width )
633 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
634 j++;
635 dst_ptr[ j * DCTSIZE + i ] = -src_ptr[ i * DCTSIZE + j ];
636 }
637 }
638 }
639 } else {
640 src_ptr = cjpeg_transupp_input5_2;
641
642 if ( dst_blk_x < comp_width ) {
643 /* Bottom-edge blocks are mirrored in x only */
644 dst_ptr = cjpeg_transupp_output_data5;
645
646 _Pragma( "loopbound min 4 max 4" )
647 for ( i = 0; i < DCTSIZE; i++ ) {
648 j = 0;
649 _Pragma( "loopbound min 8 max 8" )
650 for ( ; j < DCTSIZE; j++ )
651 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
652 i++;
653 _Pragma( "loopbound min 8 max 8" )
654 for ( j = 0; j < DCTSIZE; j++ )
655 dst_ptr[ j * DCTSIZE + i ] = -src_ptr[ i * DCTSIZE + j ];
656 }
657 } else {
658 /* At lower right corner, just transpose, no mirroring */
659 dst_ptr = cjpeg_transupp_output_data5;
660 _Pragma( "loopbound min 8 max 8" )
661 for ( i = 0; i < DCTSIZE; i++ )
662 j = 0;
663 _Pragma( "loopbound min 8 max 8" )
664 for ( ; j < DCTSIZE; j++ )
665 dst_ptr[ j * DCTSIZE + i ] = src_ptr[ i * DCTSIZE + j ];
666 }
667 }
668 dst_blk_x += compptr_h_samp_factor;
669 }
670 } while ( dst_blk_x < compptr_width_in_blocks );
671 offset_y++;
672 } while ( offset_y < compptr_v_samp_factor );
673 }
674 }
675}
676
677
678/*
679 Main functions
680*/
681
682void _Pragma ( "entrypoint" ) cjpeg_transupp_main( void )
683{
684 cjpeg_transupp_dstinfo.image_width = 227;
685 cjpeg_transupp_dstinfo.image_height = 149;
686
687 cjpeg_transupp_do_flip_v( &cjpeg_transupp_dstinfo );
688
689 cjpeg_transupp_dstinfo.image_width = 149;
690 cjpeg_transupp_dstinfo.image_height = 227;
691
692 cjpeg_transupp_do_rot_90( &cjpeg_transupp_dstinfo );
693 cjpeg_transupp_do_rot_270( &cjpeg_transupp_dstinfo );
694
695 cjpeg_transupp_dstinfo.image_width = 227;
696 cjpeg_transupp_dstinfo.image_height = 149;
697
698 cjpeg_transupp_do_rot_180( &cjpeg_transupp_dstinfo );
699
700 cjpeg_transupp_dstinfo.image_width = 149;
701 cjpeg_transupp_dstinfo.image_height = 227;
702
703 cjpeg_transupp_do_transverse( &cjpeg_transupp_dstinfo );
704}
705
706
707int main(int argc, char **argv)
708{
709 SET_UP
710 for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){
711 START_LOOP
712 cjpeg_transupp_init();
713 cjpeg_transupp_main();
714 STOP_LOOP
715 }
716 WRITE_TO_FILE
717 return ( cjpeg_transupp_return() - 660 != 0 );
718}
diff --git a/baseline/source/cjpeg_transupp/jpeglib.h b/baseline/source/cjpeg_transupp/jpeglib.h
new file mode 100644
index 0000000..bb4c940
--- /dev/null
+++ b/baseline/source/cjpeg_transupp/jpeglib.h
@@ -0,0 +1,757 @@
1/*
2
3 This program is part of the TACLeBench benchmark suite.
4 Version V 2.0
5
6 Name: jpeglib
7
8 Author: Thomas G. Lane
9
10 Function: This file defines the application interface for the JPEG library.
11 Most applications using the library need only include this file, and perhaps
12 jerror.h if they want to know the exact error codes.
13
14 Source: MediaBench II
15 http://euler.slu.edu/~fritts/mediabench (mirror)
16
17 Original name: cjpeg
18
19 Changes: No major functional changes.
20
21 License: See the accompanying README file.
22
23*/
24
25
26#ifndef JPEGLIB_H
27#define JPEGLIB_H
28
29/*
30 Various constants determining the sizes of things.
31 All of these are specified by the JPEG standard, so don't change them if you
32 want to be compatible.
33*/
34
35/* The basic DCT block is 8x8 samples */
36#define DCTSIZE 8
37
38/* DCTSIZE squared; # of elements in a block */
39#define DCTSIZE2 64
40
41
42/*
43 Data structures for images (arrays of samples and of DCT coefficients).
44 On 80x86 machines, the image arrays are too big for near pointers, but the
45 pointer arrays can fit in near memory.
46*/
47
48/* ptr to one image row of pixel samples. */
49typedef unsigned char *JSAMPROW;
50
51/* ptr to some rows (a 2-D sample array) */
52typedef JSAMPROW *JSAMPARRAY;
53
54/* one block of coefficients */
55typedef signed char JBLOCK[DCTSIZE2];
56
57/* pointer to one row of coefficient blocks */
58typedef JBLOCK *JBLOCKROW;
59
60/* a 2-D array of coefficient blocks */
61typedef JBLOCKROW *JBLOCKARRAY;
62
63/* useful in a couple of places */
64typedef signed char *JCOEFPTR;
65
66
67/*
68 DCT coefficient quantization tables.
69*/
70
71typedef struct {
72 /* quantization step for each coefficient */
73 /*
74 This array gives the coefficient quantizers in natural array order (not the
75 zigzag order in which they are stored in a JPEG DQT marker).
76 CAUTION: IJG versions prior to v6a kept this array in zigzag order.
77 */
78 unsigned short quantval[ DCTSIZE2 ];
79
80 /* 1 when table has been output */
81 /*
82 This field is used only during compression. It's initialized 0 when the
83 table is created, and set 1 when it's been output to the file. You could
84 suppress output of a table by setting this to 1. (See jpeg_suppress_tables
85 for an example.)
86 */
87 int sent_table;
88} JQUANT_TBL;
89
90
91/*
92 Huffman coding tables.
93*/
94
95typedef struct {
96 /* These two fields directly represent the contents of a JPEG DHT marker */
97
98 /* bits[k] = # of symbols with codes of */
99 /* length k bits; bits[0] is unused */
100 unsigned char bits[ 17 ];
101
102 /* The symbols, in order of incr code length */
103 /*
104 This field is used only during compression. It's initialized 0 when the
105 table is created, and set 1 when it's been output to the file. You could
106 suppress output of a table by setting this to 1. (See jpeg_suppress_tables
107 for an example.)
108 */
109 unsigned char huffval[ 256 ];
110
111 /* 1 when table has been output */
112 int sent_table;
113} JHUFF_TBL;
114
115
116/*
117 Basic info about one component (color channel).
118*/
119
120typedef struct {
121 /*
122 These values are fixed over the whole image. For compression, they must be
123 supplied by parameter setup; for decompression, they are read from the SOF
124 marker.
125 */
126
127 /* identifier for this component (0..255) */
128 int component_id;
129
130 /* its index in SOF or cinfo->comp_info[] */
131 int component_index;
132
133 /* horizontal sampling factor (1..4) */
134 int h_samp_factor;
135
136 /* vertical sampling factor (1..4) */
137 int v_samp_factor;
138
139 /* quantization table selector (0..3) */
140 int quant_tbl_no;
141
142 /*
143 These values may vary between scans. For compression, they must be supplied
144 by parameter setup; for decompression, they are read from the SOS marker.
145 The decompressor output side may not use these variables.
146 */
147
148 /* DC entropy table selector (0..3) */
149 int dc_tbl_no;
150
151 /* AC entropy table selector (0..3) */
152 int ac_tbl_no;
153
154 /* Remaining fields should be treated as private by applications. */
155
156 /*
157 These values are computed during compression or decompression startup:
158 Component's size in DCT blocks. Any dummy blocks added to complete an MCU
159 are not counted; therefore these values do not depend on whether a scan is
160 interleaved or not.
161 */
162 unsigned int width_in_blocks;
163 unsigned int height_in_blocks;
164
165 /*
166 Size of a DCT block in samples. Always DCTSIZE for compression. For
167 decompression this is the size of the output from one DCT block, reflecting
168 any scaling we choose to apply during the IDCT step. Values of 1,2,4,8 are
169 likely to be supported. Note that different components may receive different
170 IDCT scalings.
171 */
172 int DCT_scaled_size;
173
174 /*
175 The downsampled dimensions are the component's actual, unpadded number of
176 samples at the main buffer (preprocessing/compression interface), thus
177 downsampled_width = ceil(image_width * Hi/Hmax) and similarly for height.
178 For decompression, IDCT scaling is included, so
179 downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
180 */
181
182 /* actual width in samples */
183 unsigned int downsampled_width;
184
185 /* actual height in samples */
186 unsigned int downsampled_height;
187
188 /*
189 This flag is used only for decompression. In cases where some of the
190 components will be ignored (eg grayscale output from YCbCr image), we can
191 skip most computations for the unused components.
192 */
193
194 /* do we need the value of this component? */
195 int component_needed;
196
197 /*
198 These values are computed before starting a scan of the component. The
199 decompressor output side may not use these variables.
200 */
201
202 /* number of blocks per MCU, horizontally */
203 int MCU_width;
204
205 /* number of blocks per MCU, vertically */
206 int MCU_height;
207
208 /* MCU_width * MCU_height */
209 int MCU_blocks;
210
211 /* MCU width in samples, MCU_width*DCT_scaled_size */
212 int MCU_sample_width;
213
214 /* # of non-dummy blocks across in last MCU */
215 int last_col_width;
216
217 /* # of non-dummy blocks down in last MCU */
218 int last_row_height;
219
220 /*
221 Saved quantization table for component; (void*)0 if none yet saved. See
222 jdinput.c comments about the need for this information. This field is
223 currently used only for decompression.
224 */
225 JQUANT_TBL *quant_table;
226
227 /* Private per-component storage for DCT or IDCT subsystem. */
228 void *dct_table;
229} jpeg_component_info;
230
231
232/*
233 The script for encoding a multiple-scan file is an array of these:
234*/
235
236typedef struct {
237 /* number of components encoded in this scan */
238 int comps_in_scan;
239
240 /* their SOF/comp_info[] indexes */
241 int component_index[ 4 ];
242
243 /* progressive JPEG spectral selection parms */
244 int Ss, Se;
245
246 /* progressive JPEG successive approx. parms */
247 int Ah, Al;
248} jpeg_scan_info;
249
250
251/*
252 Known color spaces.
253*/
254
255typedef enum {
256 /* error/unspecified */
257 JCS_UNKNOWN,
258
259 /* monochrome */
260 JCS_GRAYSCALE,
261
262 /* red/green/blue */
263 JCS_RGB,
264
265 /* Y/Cb/Cr (also known as YUV) */
266 JCS_YCbCr,
267
268 /* C/M/Y/K */
269 JCS_CMYK,
270
271 /* Y/Cb/Cr/K */
272 JCS_YCCK
273} J_COLOR_SPACE;
274
275
276/*
277 DCT/IDCT algorithm options.
278*/
279
280typedef enum {
281 /* slow but accurate integer algorithm */
282 JDCT_ISLOW,
283
284 /* faster, less accurate integer method */
285 JDCT_IFAST,
286
287 /* floating-point: accurate, fast on fast HW */
288 JDCT_FLOAT
289} J_DCT_METHOD;
290
291
292/*
293 Common fields between JPEG compression and decompression master structs.
294*/
295
296#define jpeg_common_fields \
297 /* Error handler module */\
298 struct jpeg_error_mgr *err; \
299 /* Memory manager module */\
300 struct jpeg_memory_mgr *mem; \
301 /* Progress monitor, or (void*)0 if none */\
302 struct jpeg_progress_mgr *progress; \
303 /* Available for use by application */\
304 void *client_data; \
305 /* So common code can tell which is which */\
306 int is_decompressor; \
307 /* For checking call sequence validity */\
308 int global_state
309
310
311/*
312 Routines that are to be used by both halves of the library are declared to
313 receive a pointer to this structure. There are no actual instances of
314 jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
315*/
316
317struct jpeg_common_struct {
318 /* Fields common to both master struct types */
319 jpeg_common_fields;
320
321 /*
322 Additional fields follow in an actual jpeg_compress_struct or
323 jpeg_decompress_struct. All three structs must agree on these initial
324 fields! (This would be a lot cleaner in C++.)
325 */
326};
327
328typedef struct jpeg_common_struct *j_common_ptr;
329typedef struct jpeg_compress_struct *j_compress_ptr;
330typedef struct jpeg_decompress_struct *j_decompress_ptr;
331
332
333/*
334 Master record for a compression instance
335*/
336
337struct jpeg_compress_struct {
338 /* Fields shared with jpeg_decompress_struct */
339 jpeg_common_fields;
340
341 /* Destination for compressed data */
342 struct jpeg_destination_mgr *dest;
343
344 /*
345 Description of source image --- these fields must be filled in by outer
346 application before starting compression. in_color_space must be correct
347 before you can even call jpeg_set_defaults().
348 */
349
350 /* input image width */
351 unsigned int image_width;
352
353 /* input image height */
354 unsigned int image_height;
355
356 /* # of color components in input image */
357 int input_components;
358
359 /* colorspace of input image */
360 J_COLOR_SPACE in_color_space;
361
362 /* image gamma of input image */
363 double input_gamma;
364
365 /*
366 Compression parameters --- these fields must be set before calling
367 jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
368 initialize everything to reasonable defaults, then changing anything the
369 application specifically wants to change. That way you won't get burnt when
370 new parameters are added. Also note that there are several helper routines
371 to simplify changing parameters.
372 */
373
374 /* bits of precision in image data */
375 int data_precision;
376
377 /* # of color components in JPEG image */
378 int num_components;
379
380 /* colorspace of JPEG image */
381 J_COLOR_SPACE jpeg_color_space;
382
383 /* comp_info[i] describes component that appears i'th in SOF */
384 jpeg_component_info *comp_info;
385
386 /* ptrs to coefficient quantization tables, or (void*)0 if not defined */
387 JQUANT_TBL *quant_tbl_ptrs[ 4 ];
388
389 /* ptrs to Huffman coding tables, or (void*)0 if not defined */
390 JHUFF_TBL *dc_huff_tbl_ptrs[ 4 ];
391 JHUFF_TBL *ac_huff_tbl_ptrs[ 4 ];
392
393 /* L values for DC arith-coding tables */
394 unsigned char arith_dc_L[ 16 ];
395
396 /* U values for DC arith-coding tables */
397 unsigned char arith_dc_U[ 16 ];
398
399 /* Kx values for AC arith-coding tables */
400 unsigned char arith_ac_K[ 16 ];
401
402 /* # of entries in scan_info array */
403 int num_scans;
404
405 /*
406 script for multi-scan file, or (void*)0
407 The default value of scan_info is (void*)0, which causes a single-scan
408 sequential JPEG file to be emitted. To create a multi-scan file, set
409 num_scans and scan_info to point to an array of scan definitions.
410 */
411 const jpeg_scan_info *scan_info;
412
413 /* 1=caller supplies downsampled data */
414 int raw_data_in;
415
416 /* 1=arithmetic coding, 0=Huffman */
417 int arith_code;
418
419 /* 1=optimize entropy encoding parms */
420 int optimize_coding;
421
422 /* 1=first samples are cosited */
423 int CCIR601_sampling;
424
425 /* 1..100, or 0 for no input smoothing */
426 int smoothing_factor;
427
428 /* DCT algorithm selector */
429 J_DCT_METHOD dct_method;
430
431
432 /*
433 The restart interval can be specified in absolute MCUs by setting
434 restart_interval, or in MCU rows by setting restart_in_rows (in which case
435 the correct restart_interval will be figured for each scan).
436 */
437
438 /* MCUs per restart, or 0 for no restart */
439 unsigned int restart_interval;
440
441 /* if > 0, MCU rows per restart interval */
442 int restart_in_rows;
443
444
445 /*
446 Parameters controlling emission of special markers.
447 */
448
449 /* should a JFIF marker be written? */
450 int write_JFIF_header;
451
452 /* What to write for the JFIF version number */
453 unsigned char JFIF_major_version;
454 unsigned char JFIF_minor_version;
455
456 /*
457 These three values are not used by the JPEG code, merely copied into the
458 JFIF APP0 marker. density_unit can be 0 for unknown, 1 for dots/inch, or 2
459 for dots/cm. Note that the pixel aspect ratio is defined by
460 X_density/Y_density even when density_unit=0.
461 */
462
463 /* JFIF code for pixel size units */
464 unsigned char density_unit;
465
466 /* Horizontal pixel density */
467 unsigned short X_density;
468
469 /* Vertical pixel density */
470 unsigned short Y_density;
471
472 /* should an Adobe marker be written? */
473 int write_Adobe_marker;
474
475 /*
476 State variable: index of next scanline to be written to
477 jpeg_write_scanlines(). Application may use this to control its processing
478 loop, e.g., "while (next_scanline < image_height)".
479 */
480
481 /* 0 .. image_height-1 */
482 unsigned int next_scanline;
483
484
485 /*
486 Remaining fields are known throughout compressor, but generally should not
487 be touched by a surrounding application.
488 */
489
490 /*
491 These fields are computed during compression startup
492 */
493
494 /* 1 if scan script uses progressive mode */
495 int progressive_mode;
496
497 /* largest h_samp_factor */
498 int max_h_samp_factor;
499
500 /* largest v_samp_factor */
501 int max_v_samp_factor;
502
503 /*
504 # of iMCU rows to be input to coef ctlr
505 The coefficient controller receives data in units of MCU rows as defined for
506 fully interleaved scans (whether the JPEG file is interleaved or not). There
507 are v_samp_factor * DCTSIZE sample rows of each component in an "iMCU"
508 (interleaved MCU) row.
509 */
510 unsigned int total_iMCU_rows;
511
512 /*
513 These fields are valid during any one scan. They describe the components
514 and MCUs actually appearing in the scan.
515 */
516
517 /* # of JPEG components in this scan */
518 int comps_in_scan;
519
520 /* *cur_comp_info[i] describes component that appears i'th in SOS */
521 jpeg_component_info *cur_comp_info[ 4 ];
522
523 /* # of MCUs across the image */
524 unsigned int MCUs_per_row;
525
526 /* # of MCU rows in the image */
527 unsigned int MCU_rows_in_scan;
528
529 /* # of DCT blocks per MCU */
530 int blocks_in_MCU;
531
532 /*
533 MCU_membership[i] is index in cur_comp_info of component owning i'th block
534 in an MCU
535 */
536 int MCU_membership[ 10 ];
537
538 /* progressive JPEG parameters for scan */
539 int Ss, Se, Ah, Al;
540
541 /*
542 Links to compression subobjects (methods and private variables of modules)
543 */
544
545 struct jpeg_comp_master *master;
546 struct jpeg_c_main_controller *main;
547 struct jpeg_c_prep_controller *prep;
548 struct jpeg_c_coef_controller *coef;
549 struct jpeg_marker_writer *marker;
550 struct jpeg_color_converter *cconvert;
551 struct jpeg_downsampler *downsample;
552 struct jpeg_forward_dct *fdct;
553 struct jpeg_entropy_encoder *entropy;
554
555 /* workspace for jpeg_simple_progression */
556 jpeg_scan_info *script_space;
557
558 int script_space_size;
559};
560
561
562/*
563 "Object" declarations for JPEG modules that may be supplied or called directly
564 by the surrounding application. As with all objects in the JPEG library, these
565 structs only define the publicly visible methods and state variables of a
566 module. Additional private fields may exist after the public ones.
567*/
568
569/*
570 Error handler object
571*/
572
573struct jpeg_error_mgr {
574 /* Error exit handler: does not return to caller */
575 void ( *error_exit ) ( j_common_ptr cinfo );
576
577 /* Conditionally emit a trace or warning message */
578 void ( *emit_message ) ( j_common_ptr cinfo, int msg_level );
579
580 /* Routine that actually outputs a trace or error message */
581 void ( *output_message ) ( j_common_ptr cinfo );
582
583 /* Format a message string for the most recent JPEG error or message */
584 void ( *format_message ) ( j_common_ptr cinfo, char *buffer );
585
586 /* Reset error state variables at start of a new image */
587 void ( *reset_error_mgr ) ( j_common_ptr cinfo );
588
589 /*
590 The message ID code and any parameters are saved here. A message can have
591 one string parameter or up to 8 int parameters.
592 */
593 int msg_code;
594
595 union {
596 int i[ 8 ];
597 char s[ 80 ];
598 } msg_parm;
599
600
601 /*
602 Standard state variables for error facility
603 */
604
605 /* max msg_level that will be displayed */
606 int trace_level;
607
608 /*
609 For recoverable corrupt-data errors, we emit a warning message, but keep
610 going unless emit_message chooses to abort. emit_message should count
611 warnings in num_warnings. The surrounding application can check for bad data
612 by seeing if num_warnings is nonzero at the end of processing.
613 */
614
615 /* number of corrupt-data warnings */
616 long num_warnings;
617
618 /*
619 These fields point to the table(s) of error message strings. An application
620 can change the table pointer to switch to a different message list
621 (typically, to change the language in which errors are reported). Some
622 applications may wish to add additional error codes that will be handled by
623 the JPEG library error mechanism; the second table pointer is used for this
624 purpose.
625
626 First table includes all errors generated by JPEG library itself. Error
627 code 0 is reserved for a "no such error string" message.
628 */
629
630 /* Library errors */
631 const char *const *jpeg_message_table;
632
633 /* Table contains strings 0..last_jpeg_message */
634 int last_jpeg_message;
635
636 /*
637 Second table can be added by application (see cjpeg/djpeg for example). It
638 contains strings numbered first_addon_message..last_addon_message.
639 */
640
641 /* Non-library errors */
642 const char *const *addon_message_table;
643
644 /* code for first string in addon table */
645 int first_addon_message;
646
647 /* code for last string in addon table */
648 int last_addon_message;
649};
650
651
652/*
653 Progress monitor object
654*/
655
656struct jpeg_progress_mgr {
657 void ( *progress_monitor ) ( j_common_ptr cinfo );
658
659 /* work units completed in this pass */
660 long pass_counter;
661
662 /* total number of work units in this pass */
663 long pass_limit;
664
665 /* passes completed so far */
666 int completed_passes;
667
668 /* total number of passes expected */
669 int total_passes;
670};
671
672
673/*
674 Data destination object for compression
675*/
676
677struct jpeg_destination_mgr {
678 /* => next byte to write in buffer */
679 unsigned char *next_output_byte;
680
681 /* # of byte spaces remaining in buffer */
682 long unsigned int free_in_buffer;
683
684 void ( *init_destination ) ( j_compress_ptr cinfo );
685 int ( *empty_output_buffer ) ( j_compress_ptr cinfo );
686 void ( *term_destination ) ( j_compress_ptr cinfo );
687};
688
689
690/*
691 Memory manager object.
692 Allocates "small" objects (a few K total), "large" objects (tens of K), and
693 "really big" objects (virtual arrays with backing store if needed). The memory
694 manager does not allow individual objects to be freed; rather, each created
695 object is assigned to a pool, and whole pools can be freed at once. This is
696 faster and more convenient than remembering exactly what to free, especially
697 where malloc()/free() are not too speedy.
698 NB: alloc routines never return (void*)0. They exit to error_exit if not
699 successful.
700*/
701
702typedef struct jvirt_sarray_control *jvirt_sarray_ptr;
703typedef struct jvirt_barray_control *jvirt_barray_ptr;
704
705struct jpeg_memory_mgr {
706 /*
707 Method pointers
708 */
709 void *( *alloc_small ) (
710 j_common_ptr cinfo, int pool_id, long unsigned int sizeofobject );
711
712 void *( *alloc_large ) (
713 j_common_ptr cinfo, int pool_id, long unsigned int sizeofobject );
714
715 JSAMPARRAY ( *alloc_sarray ) (
716 j_common_ptr cinfo, int pool_id, unsigned int samplesperrow,
717 unsigned int numrows );
718
719 JBLOCKARRAY ( *alloc_barray )(
720 j_common_ptr cinfo, int pool_id, unsigned int blocksperrow,
721 unsigned int numrows );
722
723 jvirt_sarray_ptr ( *request_virt_sarray ) (
724 j_common_ptr cinfo, int pool_id, int pre_zero, unsigned int samplesperrow,
725 unsigned int numrows, unsigned int maxaccess );
726
727 jvirt_barray_ptr ( *request_virt_barray ) (
728 j_common_ptr cinfo, int pool_id, int pre_zero, unsigned int blocksperrow,
729 unsigned int numrows, unsigned int maxaccess );
730
731 void ( *realize_virt_arrays ) ( j_common_ptr cinfo );
732
733 JSAMPARRAY ( *access_virt_sarray ) (
734 j_common_ptr cinfo, jvirt_sarray_ptr ptr, unsigned int start_row,
735 unsigned int num_rows, int writable );
736
737 JBLOCKARRAY ( *access_virt_barray ) (
738 j_common_ptr cinfo, jvirt_barray_ptr ptr, unsigned int start_row,
739 unsigned int num_rows, int writable );
740
741 void ( *free_pool ) ( j_common_ptr cinfo, int pool_id );
742
743 void ( *self_destruct ) ( j_common_ptr cinfo );
744
745 /*
746 Limit on memory allocation for this JPEG object. (Note that this is merely
747 advisory, not a guaranteed maximum; it only affects the space used for
748 virtual-array buffers.) May be changed by outer application after creating
749 the JPEG object.
750 */
751 long max_memory_to_use;
752
753 /* Maximum allocation request accepted by alloc_large. */
754 long max_alloc_chunk;
755};
756
757#endif /* JPEGLIB_H */