diff options
author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
---|---|---|
committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
commit | 386b7d3366f1359a265da207a9cafa3edf553b64 (patch) | |
tree | c76120c2c138faed822e4ae386be6ef22a738a78 /baseline/source/cjpeg_transupp/cjpeg_transupp.c | |
parent | 54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff) |
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'baseline/source/cjpeg_transupp/cjpeg_transupp.c')
-rw-r--r-- | baseline/source/cjpeg_transupp/cjpeg_transupp.c | 718 |
1 files changed, 718 insertions, 0 deletions
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 | |||
40 | void cjpeg_transupp_initSeed( void ); | ||
41 | signed char cjpeg_transupp_randomInteger( void ); | ||
42 | void cjpeg_transupp_init( void ); | ||
43 | int cjpeg_transupp_return( void ); | ||
44 | void cjpeg_transupp_do_flip_v( j_compress_ptr ); | ||
45 | void cjpeg_transupp_do_rot_90( j_compress_ptr ); | ||
46 | void cjpeg_transupp_do_rot_180( j_compress_ptr ); | ||
47 | void cjpeg_transupp_do_rot_270( j_compress_ptr ); | ||
48 | void cjpeg_transupp_do_transverse( j_compress_ptr ); | ||
49 | void cjpeg_transupp_main( void ); | ||
50 | //int main( void ); | ||
51 | |||
52 | |||
53 | /* | ||
54 | Declaration of global variables | ||
55 | */ | ||
56 | |||
57 | volatile int cjpeg_transupp_seed; | ||
58 | |||
59 | signed char cjpeg_transupp_input[ 256 ]; | ||
60 | signed char cjpeg_transupp_input2[ 80 ]; | ||
61 | signed char cjpeg_transupp_input3[ 65 ]; | ||
62 | signed char cjpeg_transupp_input3_2[ 65 ]; | ||
63 | signed char cjpeg_transupp_input4[ 64 ]; | ||
64 | signed char cjpeg_transupp_input5[ 65 ]; | ||
65 | signed char cjpeg_transupp_input5_2[ 65 ]; | ||
66 | |||
67 | /* Output arrays replace writing of results into a file. */ | ||
68 | signed char cjpeg_transupp_output_data[ 512 ]; | ||
69 | signed char cjpeg_transupp_output_data2[ 512 ]; | ||
70 | signed char cjpeg_transupp_output_data3[ 512 ]; | ||
71 | signed char cjpeg_transupp_output_data4[ 512 ]; | ||
72 | signed char cjpeg_transupp_output_data5[ 512 ]; | ||
73 | |||
74 | struct jpeg_compress_struct cjpeg_transupp_dstinfo; | ||
75 | |||
76 | |||
77 | /* | ||
78 | Initialization- and return-value-related functions | ||
79 | */ | ||
80 | |||
81 | void 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 | */ | ||
90 | signed 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 | |||
97 | void 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 | |||
138 | int 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 | */ | ||
175 | void 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 | */ | ||
253 | void 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 | */ | ||
342 | void 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 | */ | ||
428 | void 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 | */ | ||
561 | void 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 | |||
682 | void _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 | |||
707 | int 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 | } | ||