diff options
author | Zhai Edwin <edwin.zhai@intel.com> | 2010-07-15 13:34:26 +0800 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-07-21 16:00:54 +0100 |
commit | b8b678f01099d40f1412386957b2fe457dd9c0ae (patch) | |
tree | 8deecda0737801ba23fcec95a012c58cf8fa928e /meta/packages/jpeg/jpeg-6b | |
parent | 37eb35995f3d4d75ef57987d5d924b23c40e83e2 (diff) | |
download | poky-b8b678f01099d40f1412386957b2fe457dd9c0ae.tar.gz |
jpeg: Update to 8b
Original patch status:
ldflags.patch:
paths.patch:
libtool_tweak.patch:
Dropped as the issues got fixed in 8b
debian.patch:
This patch comes from debian distro. Original version can't apply, so
replace it by latest version
Signed-off-by: Zhai Edwin <edwin.zhai@intel.com>
Diffstat (limited to 'meta/packages/jpeg/jpeg-6b')
-rw-r--r-- | meta/packages/jpeg/jpeg-6b/debian.patch | 1874 | ||||
-rw-r--r-- | meta/packages/jpeg/jpeg-6b/ldflags.patch | 16 | ||||
-rw-r--r-- | meta/packages/jpeg/jpeg-6b/libtool_tweak.patch | 52 | ||||
-rw-r--r-- | meta/packages/jpeg/jpeg-6b/paths.patch | 77 |
4 files changed, 0 insertions, 2019 deletions
diff --git a/meta/packages/jpeg/jpeg-6b/debian.patch b/meta/packages/jpeg/jpeg-6b/debian.patch deleted file mode 100644 index a169ad19d6..0000000000 --- a/meta/packages/jpeg/jpeg-6b/debian.patch +++ /dev/null | |||
@@ -1,1874 +0,0 @@ | |||
1 | --- jpeg-6b/jpegtran.1~libjpeg6bb-5 | ||
2 | +++ jpeg-6b/jpegtran.1 | ||
3 | @@ -131,6 +131,24 @@ | ||
4 | .B \-rot 180 -trim | ||
5 | trims both edges. | ||
6 | .PP | ||
7 | +We also offer a lossless-crop option, which discards data outside a given | ||
8 | +image region but losslessly preserves what is inside. Like the rotate and | ||
9 | +flip transforms, lossless crop is restricted by the JPEG format: the upper | ||
10 | +left corner of the selected region must fall on an iMCU boundary. If this | ||
11 | +does not hold for the given crop parameters, we silently move the upper left | ||
12 | +corner up and/or left to make it so, simultaneously increasing the region | ||
13 | +dimensions to keep the lower right crop corner unchanged. (Thus, the | ||
14 | +output image covers at least the requested region, but may cover more.) | ||
15 | + | ||
16 | +Note: lossless-crop is an enhancement from http://sylvana.net/jpegcrop/ | ||
17 | +that may not be available on non-Debian systems. | ||
18 | + | ||
19 | +The image can be losslessly cropped by giving the switch: | ||
20 | +.TP | ||
21 | +.B \-crop WxH+X+Y | ||
22 | +Crop to a rectangular subarea of width W, height H starting at point X,Y. | ||
23 | +.PP | ||
24 | +.PP | ||
25 | Another not-strictly-lossless transformation switch is: | ||
26 | .TP | ||
27 | .B \-grayscale | ||
28 | --- jpeg-6b/configure~libjpeg6bb-5 | ||
29 | +++ jpeg-6b/configure | ||
30 | @@ -52,7 +52,7 @@ | ||
31 | includedir='${prefix}/include' | ||
32 | oldincludedir='/usr/include' | ||
33 | infodir='${prefix}/info' | ||
34 | -mandir='${prefix}/man' | ||
35 | +mandir='${prefix}/share/man' | ||
36 | |||
37 | # Initialize some other variables. | ||
38 | subdirs= | ||
39 | --- jpeg-6b/makefile.cfg~libjpeg6bb-5 | ||
40 | +++ jpeg-6b/makefile.cfg | ||
41 | @@ -17,7 +17,7 @@ | ||
42 | binprefix = | ||
43 | manprefix = | ||
44 | manext = 1 | ||
45 | -mandir = $(prefix)/man/man$(manext) | ||
46 | +mandir = $(prefix)/share/man/man$(manext) | ||
47 | |||
48 | # The name of your C compiler: | ||
49 | CC= @CC@ | ||
50 | @@ -210,6 +210,11 @@ | ||
51 | $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h | ||
52 | $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h | ||
53 | $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h | ||
54 | +#<ballombe@debian.org>:mjpegtools require this file to build and header say: | ||
55 | +# * These declarations are considered internal to the JPEG library; most | ||
56 | +# * applications using the library shouldn't need to include this file. | ||
57 | +# So it is not forbidden to use it, therefore it must be installed. | ||
58 | + $(INSTALL_DATA) $(srcdir)/jpegint.h $(includedir)/jpegint.h | ||
59 | |||
60 | clean: | ||
61 | $(RM) *.o *.lo libjpeg.a libjpeg.la | ||
62 | --- jpeg-6b/jpegtran.c~libjpeg6bb-5 | ||
63 | +++ jpeg-6b/jpegtran.c | ||
64 | @@ -1,7 +1,7 @@ | ||
65 | /* | ||
66 | * jpegtran.c | ||
67 | * | ||
68 | - * Copyright (C) 1995-1997, Thomas G. Lane. | ||
69 | + * Copyright (C) 1995-2001, Thomas G. Lane. | ||
70 | * This file is part of the Independent JPEG Group's software. | ||
71 | * For conditions of distribution and use, see the accompanying README file. | ||
72 | * | ||
73 | @@ -64,6 +64,7 @@ | ||
74 | #endif | ||
75 | #if TRANSFORMS_SUPPORTED | ||
76 | fprintf(stderr, "Switches for modifying the image:\n"); | ||
77 | + fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n"); | ||
78 | fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); | ||
79 | fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); | ||
80 | fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); | ||
81 | @@ -134,6 +135,7 @@ | ||
82 | transformoption.transform = JXFORM_NONE; | ||
83 | transformoption.trim = FALSE; | ||
84 | transformoption.force_grayscale = FALSE; | ||
85 | + transformoption.crop = FALSE; | ||
86 | cinfo->err->trace_level = 0; | ||
87 | |||
88 | /* Scan command line options, adjust parameters */ | ||
89 | @@ -160,7 +162,7 @@ | ||
90 | exit(EXIT_FAILURE); | ||
91 | #endif | ||
92 | |||
93 | - } else if (keymatch(arg, "copy", 1)) { | ||
94 | + } else if (keymatch(arg, "copy", 2)) { | ||
95 | /* Select which extra markers to copy. */ | ||
96 | if (++argn >= argc) /* advance to next argument */ | ||
97 | usage(); | ||
98 | @@ -173,6 +175,20 @@ | ||
99 | } else | ||
100 | usage(); | ||
101 | |||
102 | + } else if (keymatch(arg, "crop", 2)) { | ||
103 | + /* Perform lossless cropping. */ | ||
104 | +#if TRANSFORMS_SUPPORTED | ||
105 | + if (++argn >= argc) /* advance to next argument */ | ||
106 | + usage(); | ||
107 | + if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) { | ||
108 | + fprintf(stderr, "%s: bogus -crop argument '%s'\n", | ||
109 | + progname, argv[argn]); | ||
110 | + exit(EXIT_FAILURE); | ||
111 | + } | ||
112 | +#else | ||
113 | + select_transform(JXFORM_NONE); /* force an error */ | ||
114 | +#endif | ||
115 | + | ||
116 | } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { | ||
117 | /* Enable debug printouts. */ | ||
118 | /* On first -d, print version identification */ | ||
119 | @@ -342,8 +358,10 @@ | ||
120 | jvirt_barray_ptr * src_coef_arrays; | ||
121 | jvirt_barray_ptr * dst_coef_arrays; | ||
122 | int file_index; | ||
123 | - FILE * input_file; | ||
124 | - FILE * output_file; | ||
125 | + /* We assume all-in-memory processing and can therefore use only a | ||
126 | + * single file pointer for sequential input and output operation. | ||
127 | + */ | ||
128 | + FILE * fp; | ||
129 | |||
130 | /* On Mac, fetch a command line. */ | ||
131 | #ifdef USE_CCOMMAND | ||
132 | @@ -406,24 +424,13 @@ | ||
133 | |||
134 | /* Open the input file. */ | ||
135 | if (file_index < argc) { | ||
136 | - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { | ||
137 | + if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) { | ||
138 | fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); | ||
139 | exit(EXIT_FAILURE); | ||
140 | } | ||
141 | } else { | ||
142 | /* default input file is stdin */ | ||
143 | - input_file = read_stdin(); | ||
144 | - } | ||
145 | - | ||
146 | - /* Open the output file. */ | ||
147 | - if (outfilename != NULL) { | ||
148 | - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { | ||
149 | - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); | ||
150 | - exit(EXIT_FAILURE); | ||
151 | - } | ||
152 | - } else { | ||
153 | - /* default output file is stdout */ | ||
154 | - output_file = write_stdout(); | ||
155 | + fp = read_stdin(); | ||
156 | } | ||
157 | |||
158 | #ifdef PROGRESS_REPORT | ||
159 | @@ -431,7 +438,7 @@ | ||
160 | #endif | ||
161 | |||
162 | /* Specify data source for decompression */ | ||
163 | - jpeg_stdio_src(&srcinfo, input_file); | ||
164 | + jpeg_stdio_src(&srcinfo, fp); | ||
165 | |||
166 | /* Enable saving of extra markers that we want to copy */ | ||
167 | jcopy_markers_setup(&srcinfo, copyoption); | ||
168 | @@ -463,11 +470,32 @@ | ||
169 | dst_coef_arrays = src_coef_arrays; | ||
170 | #endif | ||
171 | |||
172 | + /* Close input file, if we opened it. | ||
173 | + * Note: we assume that jpeg_read_coefficients consumed all input | ||
174 | + * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will | ||
175 | + * only consume more while (! cinfo->inputctl->eoi_reached). | ||
176 | + * We cannot call jpeg_finish_decompress here since we still need the | ||
177 | + * virtual arrays allocated from the source object for processing. | ||
178 | + */ | ||
179 | + if (fp != stdin) | ||
180 | + fclose(fp); | ||
181 | + | ||
182 | + /* Open the output file. */ | ||
183 | + if (outfilename != NULL) { | ||
184 | + if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) { | ||
185 | + fprintf(stderr, "%s: can't open %s\n", progname, outfilename); | ||
186 | + exit(EXIT_FAILURE); | ||
187 | + } | ||
188 | + } else { | ||
189 | + /* default output file is stdout */ | ||
190 | + fp = write_stdout(); | ||
191 | + } | ||
192 | + | ||
193 | /* Adjust default compression parameters by re-parsing the options */ | ||
194 | file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); | ||
195 | |||
196 | /* Specify data destination for compression */ | ||
197 | - jpeg_stdio_dest(&dstinfo, output_file); | ||
198 | + jpeg_stdio_dest(&dstinfo, fp); | ||
199 | |||
200 | /* Start compressor (note no image data is actually written here) */ | ||
201 | jpeg_write_coefficients(&dstinfo, dst_coef_arrays); | ||
202 | @@ -488,11 +516,9 @@ | ||
203 | (void) jpeg_finish_decompress(&srcinfo); | ||
204 | jpeg_destroy_decompress(&srcinfo); | ||
205 | |||
206 | - /* Close files, if we opened them */ | ||
207 | - if (input_file != stdin) | ||
208 | - fclose(input_file); | ||
209 | - if (output_file != stdout) | ||
210 | - fclose(output_file); | ||
211 | + /* Close output file, if we opened it */ | ||
212 | + if (fp != stdout) | ||
213 | + fclose(fp); | ||
214 | |||
215 | #ifdef PROGRESS_REPORT | ||
216 | end_progress_monitor((j_common_ptr) &dstinfo); | ||
217 | --- jpeg-6b/rdjpgcom.c~libjpeg6bb-5 | ||
218 | +++ jpeg-6b/rdjpgcom.c | ||
219 | @@ -14,6 +14,7 @@ | ||
220 | #define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ | ||
221 | #include "jinclude.h" /* get auto-config symbols, <stdio.h> */ | ||
222 | |||
223 | +#include <locale.h> /*ballombe@debian.org: use locale for isprint*/ | ||
224 | #include <ctype.h> /* to declare isupper(), tolower() */ | ||
225 | #ifdef USE_SETMODE | ||
226 | #include <fcntl.h> /* to declare setmode()'s parameter macros */ | ||
227 | @@ -223,7 +224,10 @@ | ||
228 | unsigned int length; | ||
229 | int ch; | ||
230 | int lastch = 0; | ||
231 | - | ||
232 | +/* ballombe@debian.org Thu, 15 Nov 2001 20:04:47 +0100*/ | ||
233 | +/* Set locale properly for isprint*/ | ||
234 | + setlocale(LC_CTYPE,""); | ||
235 | + | ||
236 | /* Get the marker parameter length count */ | ||
237 | length = read_2_bytes(); | ||
238 | /* Length includes itself, so must be at least 2 */ | ||
239 | @@ -254,6 +258,8 @@ | ||
240 | length--; | ||
241 | } | ||
242 | printf("\n"); | ||
243 | +/*ballombe@debian.org: revert to C locale*/ | ||
244 | + setlocale(LC_CTYPE,"C"); | ||
245 | } | ||
246 | |||
247 | |||
248 | --- jpeg-6b/transupp.c~libjpeg6bb-5 | ||
249 | +++ jpeg-6b/transupp.c | ||
250 | @@ -1,7 +1,7 @@ | ||
251 | /* | ||
252 | * transupp.c | ||
253 | * | ||
254 | - * Copyright (C) 1997, Thomas G. Lane. | ||
255 | + * Copyright (C) 1997-2001, Thomas G. Lane. | ||
256 | * This file is part of the Independent JPEG Group's software. | ||
257 | * For conditions of distribution and use, see the accompanying README file. | ||
258 | * | ||
259 | @@ -20,6 +20,7 @@ | ||
260 | #include "jinclude.h" | ||
261 | #include "jpeglib.h" | ||
262 | #include "transupp.h" /* My own external interface */ | ||
263 | +#include <ctype.h> /* to declare isdigit() */ | ||
264 | |||
265 | |||
266 | #if TRANSFORMS_SUPPORTED | ||
267 | @@ -28,7 +29,8 @@ | ||
268 | * Lossless image transformation routines. These routines work on DCT | ||
269 | * coefficient arrays and thus do not require any lossy decompression | ||
270 | * or recompression of the image. | ||
271 | - * Thanks to Guido Vollbeding for the initial design and code of this feature. | ||
272 | + * Thanks to Guido Vollbeding for the initial design and code of this feature, | ||
273 | + * and to Ben Jackson for introducing the cropping feature. | ||
274 | * | ||
275 | * Horizontal flipping is done in-place, using a single top-to-bottom | ||
276 | * pass through the virtual source array. It will thus be much the | ||
277 | @@ -42,6 +44,13 @@ | ||
278 | * arrays for most of the transforms. That could result in much thrashing | ||
279 | * if the image is larger than main memory. | ||
280 | * | ||
281 | + * If cropping or trimming is involved, the destination arrays may be smaller | ||
282 | + * than the source arrays. Note it is not possible to do horizontal flip | ||
283 | + * in-place when a nonzero Y crop offset is specified, since we'd have to move | ||
284 | + * data from one block row to another but the virtual array manager doesn't | ||
285 | + * guarantee we can touch more than one row at a time. So in that case, | ||
286 | + * we have to use a separate destination array. | ||
287 | + * | ||
288 | * Some notes about the operating environment of the individual transform | ||
289 | * routines: | ||
290 | * 1. Both the source and destination virtual arrays are allocated from the | ||
291 | @@ -54,20 +63,65 @@ | ||
292 | * and we may as well take that as the effective iMCU size. | ||
293 | * 4. When "trim" is in effect, the destination's dimensions will be the | ||
294 | * trimmed values but the source's will be untrimmed. | ||
295 | - * 5. All the routines assume that the source and destination buffers are | ||
296 | + * 5. When "crop" is in effect, the destination's dimensions will be the | ||
297 | + * cropped values but the source's will be uncropped. Each transform | ||
298 | + * routine is responsible for picking up source data starting at the | ||
299 | + * correct X and Y offset for the crop region. (The X and Y offsets | ||
300 | + * passed to the transform routines are measured in iMCU blocks of the | ||
301 | + * destination.) | ||
302 | + * 6. All the routines assume that the source and destination buffers are | ||
303 | * padded out to a full iMCU boundary. This is true, although for the | ||
304 | * source buffer it is an undocumented property of jdcoefct.c. | ||
305 | - * Notes 2,3,4 boil down to this: generally we should use the destination's | ||
306 | - * dimensions and ignore the source's. | ||
307 | */ | ||
308 | |||
309 | |||
310 | LOCAL(void) | ||
311 | -do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
312 | - jvirt_barray_ptr *src_coef_arrays) | ||
313 | -/* Horizontal flip; done in-place, so no separate dest array is required */ | ||
314 | +do_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
315 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
316 | + jvirt_barray_ptr *src_coef_arrays, | ||
317 | + jvirt_barray_ptr *dst_coef_arrays) | ||
318 | +/* Crop. This is only used when no rotate/flip is requested with the crop. */ | ||
319 | { | ||
320 | - JDIMENSION MCU_cols, comp_width, blk_x, blk_y; | ||
321 | + JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; | ||
322 | + int ci, offset_y; | ||
323 | + JBLOCKARRAY src_buffer, dst_buffer; | ||
324 | + jpeg_component_info *compptr; | ||
325 | + | ||
326 | + /* We simply have to copy the right amount of data (the destination's | ||
327 | + * image size) starting at the given X and Y offsets in the source. | ||
328 | + */ | ||
329 | + for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
330 | + compptr = dstinfo->comp_info + ci; | ||
331 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
332 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
333 | + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
334 | + dst_blk_y += compptr->v_samp_factor) { | ||
335 | + dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
336 | + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, | ||
337 | + (JDIMENSION) compptr->v_samp_factor, TRUE); | ||
338 | + src_buffer = (*srcinfo->mem->access_virt_barray) | ||
339 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
340 | + dst_blk_y + y_crop_blocks, | ||
341 | + (JDIMENSION) compptr->v_samp_factor, FALSE); | ||
342 | + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
343 | + jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, | ||
344 | + dst_buffer[offset_y], | ||
345 | + compptr->width_in_blocks); | ||
346 | + } | ||
347 | + } | ||
348 | + } | ||
349 | +} | ||
350 | + | ||
351 | + | ||
352 | +LOCAL(void) | ||
353 | +do_flip_h_no_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
354 | + JDIMENSION x_crop_offset, | ||
355 | + jvirt_barray_ptr *src_coef_arrays) | ||
356 | +/* Horizontal flip; done in-place, so no separate dest array is required. | ||
357 | + * NB: this only works when y_crop_offset is zero. | ||
358 | + */ | ||
359 | +{ | ||
360 | + JDIMENSION MCU_cols, comp_width, blk_x, blk_y, x_crop_blocks; | ||
361 | int ci, k, offset_y; | ||
362 | JBLOCKARRAY buffer; | ||
363 | JCOEFPTR ptr1, ptr2; | ||
364 | @@ -79,17 +133,19 @@ | ||
365 | * mirroring by changing the signs of odd-numbered columns. | ||
366 | * Partial iMCUs at the right edge are left untouched. | ||
367 | */ | ||
368 | - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
369 | + MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
370 | |||
371 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
372 | compptr = dstinfo->comp_info + ci; | ||
373 | comp_width = MCU_cols * compptr->h_samp_factor; | ||
374 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
375 | for (blk_y = 0; blk_y < compptr->height_in_blocks; | ||
376 | blk_y += compptr->v_samp_factor) { | ||
377 | buffer = (*srcinfo->mem->access_virt_barray) | ||
378 | ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, | ||
379 | (JDIMENSION) compptr->v_samp_factor, TRUE); | ||
380 | for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
381 | + /* Do the mirroring */ | ||
382 | for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { | ||
383 | ptr1 = buffer[offset_y][blk_x]; | ||
384 | ptr2 = buffer[offset_y][comp_width - blk_x - 1]; | ||
385 | @@ -105,6 +161,79 @@ | ||
386 | *ptr2++ = -temp1; | ||
387 | } | ||
388 | } | ||
389 | + if (x_crop_blocks > 0) { | ||
390 | + /* Now left-justify the portion of the data to be kept. | ||
391 | + * We can't use a single jcopy_block_row() call because that routine | ||
392 | + * depends on memcpy(), whose behavior is unspecified for overlapping | ||
393 | + * source and destination areas. Sigh. | ||
394 | + */ | ||
395 | + for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { | ||
396 | + jcopy_block_row(buffer[offset_y] + blk_x + x_crop_blocks, | ||
397 | + buffer[offset_y] + blk_x, | ||
398 | + (JDIMENSION) 1); | ||
399 | + } | ||
400 | + } | ||
401 | + } | ||
402 | + } | ||
403 | + } | ||
404 | +} | ||
405 | + | ||
406 | + | ||
407 | +LOCAL(void) | ||
408 | +do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
409 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
410 | + jvirt_barray_ptr *src_coef_arrays, | ||
411 | + jvirt_barray_ptr *dst_coef_arrays) | ||
412 | +/* Horizontal flip in general cropping case */ | ||
413 | +{ | ||
414 | + JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; | ||
415 | + JDIMENSION x_crop_blocks, y_crop_blocks; | ||
416 | + int ci, k, offset_y; | ||
417 | + JBLOCKARRAY src_buffer, dst_buffer; | ||
418 | + JBLOCKROW src_row_ptr, dst_row_ptr; | ||
419 | + JCOEFPTR src_ptr, dst_ptr; | ||
420 | + jpeg_component_info *compptr; | ||
421 | + | ||
422 | + /* Here we must output into a separate array because we can't touch | ||
423 | + * different rows of a single virtual array simultaneously. Otherwise, | ||
424 | + * this is essentially the same as the routine above. | ||
425 | + */ | ||
426 | + MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
427 | + | ||
428 | + for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
429 | + compptr = dstinfo->comp_info + ci; | ||
430 | + comp_width = MCU_cols * compptr->h_samp_factor; | ||
431 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
432 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
433 | + for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
434 | + dst_blk_y += compptr->v_samp_factor) { | ||
435 | + dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
436 | + ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, | ||
437 | + (JDIMENSION) compptr->v_samp_factor, TRUE); | ||
438 | + src_buffer = (*srcinfo->mem->access_virt_barray) | ||
439 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
440 | + dst_blk_y + y_crop_blocks, | ||
441 | + (JDIMENSION) compptr->v_samp_factor, FALSE); | ||
442 | + for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
443 | + dst_row_ptr = dst_buffer[offset_y]; | ||
444 | + src_row_ptr = src_buffer[offset_y]; | ||
445 | + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { | ||
446 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
447 | + /* Do the mirrorable blocks */ | ||
448 | + dst_ptr = dst_row_ptr[dst_blk_x]; | ||
449 | + src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; | ||
450 | + /* this unrolled loop doesn't need to know which row it's on... */ | ||
451 | + for (k = 0; k < DCTSIZE2; k += 2) { | ||
452 | + *dst_ptr++ = *src_ptr++; /* copy even column */ | ||
453 | + *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ | ||
454 | + } | ||
455 | + } else { | ||
456 | + /* Copy last partial block(s) verbatim */ | ||
457 | + jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, | ||
458 | + dst_row_ptr + dst_blk_x, | ||
459 | + (JDIMENSION) 1); | ||
460 | + } | ||
461 | + } | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | @@ -113,11 +242,13 @@ | ||
466 | |||
467 | LOCAL(void) | ||
468 | do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
469 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
470 | jvirt_barray_ptr *src_coef_arrays, | ||
471 | jvirt_barray_ptr *dst_coef_arrays) | ||
472 | /* Vertical flip */ | ||
473 | { | ||
474 | JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; | ||
475 | + JDIMENSION x_crop_blocks, y_crop_blocks; | ||
476 | int ci, i, j, offset_y; | ||
477 | JBLOCKARRAY src_buffer, dst_buffer; | ||
478 | JBLOCKROW src_row_ptr, dst_row_ptr; | ||
479 | @@ -131,33 +262,38 @@ | ||
480 | * of odd-numbered rows. | ||
481 | * Partial iMCUs at the bottom edge are copied verbatim. | ||
482 | */ | ||
483 | - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
484 | + MCU_rows = srcinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
485 | |||
486 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
487 | compptr = dstinfo->comp_info + ci; | ||
488 | comp_height = MCU_rows * compptr->v_samp_factor; | ||
489 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
490 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
491 | for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
492 | dst_blk_y += compptr->v_samp_factor) { | ||
493 | dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
494 | ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, | ||
495 | (JDIMENSION) compptr->v_samp_factor, TRUE); | ||
496 | - if (dst_blk_y < comp_height) { | ||
497 | + if (y_crop_blocks + dst_blk_y < comp_height) { | ||
498 | /* Row is within the mirrorable area. */ | ||
499 | src_buffer = (*srcinfo->mem->access_virt_barray) | ||
500 | ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
501 | - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, | ||
502 | + comp_height - y_crop_blocks - dst_blk_y - | ||
503 | + (JDIMENSION) compptr->v_samp_factor, | ||
504 | (JDIMENSION) compptr->v_samp_factor, FALSE); | ||
505 | } else { | ||
506 | /* Bottom-edge blocks will be copied verbatim. */ | ||
507 | src_buffer = (*srcinfo->mem->access_virt_barray) | ||
508 | - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, | ||
509 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
510 | + dst_blk_y + y_crop_blocks, | ||
511 | (JDIMENSION) compptr->v_samp_factor, FALSE); | ||
512 | } | ||
513 | for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
514 | - if (dst_blk_y < comp_height) { | ||
515 | + if (y_crop_blocks + dst_blk_y < comp_height) { | ||
516 | /* Row is within the mirrorable area. */ | ||
517 | dst_row_ptr = dst_buffer[offset_y]; | ||
518 | src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; | ||
519 | + src_row_ptr += x_crop_blocks; | ||
520 | for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; | ||
521 | dst_blk_x++) { | ||
522 | dst_ptr = dst_row_ptr[dst_blk_x]; | ||
523 | @@ -173,7 +309,8 @@ | ||
524 | } | ||
525 | } else { | ||
526 | /* Just copy row verbatim. */ | ||
527 | - jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y], | ||
528 | + jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, | ||
529 | + dst_buffer[offset_y], | ||
530 | compptr->width_in_blocks); | ||
531 | } | ||
532 | } | ||
533 | @@ -184,11 +321,12 @@ | ||
534 | |||
535 | LOCAL(void) | ||
536 | do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
537 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
538 | jvirt_barray_ptr *src_coef_arrays, | ||
539 | jvirt_barray_ptr *dst_coef_arrays) | ||
540 | /* Transpose source into destination */ | ||
541 | { | ||
542 | - JDIMENSION dst_blk_x, dst_blk_y; | ||
543 | + JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; | ||
544 | int ci, i, j, offset_x, offset_y; | ||
545 | JBLOCKARRAY src_buffer, dst_buffer; | ||
546 | JCOEFPTR src_ptr, dst_ptr; | ||
547 | @@ -201,6 +339,8 @@ | ||
548 | */ | ||
549 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
550 | compptr = dstinfo->comp_info + ci; | ||
551 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
552 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
553 | for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
554 | dst_blk_y += compptr->v_samp_factor) { | ||
555 | dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
556 | @@ -210,11 +350,12 @@ | ||
557 | for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; | ||
558 | dst_blk_x += compptr->h_samp_factor) { | ||
559 | src_buffer = (*srcinfo->mem->access_virt_barray) | ||
560 | - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, | ||
561 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
562 | + dst_blk_x + x_crop_blocks, | ||
563 | (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
564 | for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { | ||
565 | - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; | ||
566 | dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
567 | + src_ptr = src_buffer[offset_x][dst_blk_y + offset_y + y_crop_blocks]; | ||
568 | for (i = 0; i < DCTSIZE; i++) | ||
569 | for (j = 0; j < DCTSIZE; j++) | ||
570 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
571 | @@ -228,6 +369,7 @@ | ||
572 | |||
573 | LOCAL(void) | ||
574 | do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
575 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
576 | jvirt_barray_ptr *src_coef_arrays, | ||
577 | jvirt_barray_ptr *dst_coef_arrays) | ||
578 | /* 90 degree rotation is equivalent to | ||
579 | @@ -237,6 +379,7 @@ | ||
580 | */ | ||
581 | { | ||
582 | JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; | ||
583 | + JDIMENSION x_crop_blocks, y_crop_blocks; | ||
584 | int ci, i, j, offset_x, offset_y; | ||
585 | JBLOCKARRAY src_buffer, dst_buffer; | ||
586 | JCOEFPTR src_ptr, dst_ptr; | ||
587 | @@ -246,11 +389,13 @@ | ||
588 | * at the (output) right edge properly. They just get transposed and | ||
589 | * not mirrored. | ||
590 | */ | ||
591 | - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
592 | + MCU_cols = srcinfo->image_height / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
593 | |||
594 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
595 | compptr = dstinfo->comp_info + ci; | ||
596 | comp_width = MCU_cols * compptr->h_samp_factor; | ||
597 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
598 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
599 | for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
600 | dst_blk_y += compptr->v_samp_factor) { | ||
601 | dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
602 | @@ -259,15 +404,26 @@ | ||
603 | for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
604 | for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; | ||
605 | dst_blk_x += compptr->h_samp_factor) { | ||
606 | - src_buffer = (*srcinfo->mem->access_virt_barray) | ||
607 | - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, | ||
608 | - (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
609 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
610 | + /* Block is within the mirrorable area. */ | ||
611 | + src_buffer = (*srcinfo->mem->access_virt_barray) | ||
612 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
613 | + comp_width - x_crop_blocks - dst_blk_x - | ||
614 | + (JDIMENSION) compptr->h_samp_factor, | ||
615 | + (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
616 | + } else { | ||
617 | + /* Edge blocks are transposed but not mirrored. */ | ||
618 | + src_buffer = (*srcinfo->mem->access_virt_barray) | ||
619 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
620 | + dst_blk_x + x_crop_blocks, | ||
621 | + (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
622 | + } | ||
623 | for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { | ||
624 | - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; | ||
625 | - if (dst_blk_x < comp_width) { | ||
626 | + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
627 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
628 | /* Block is within the mirrorable area. */ | ||
629 | - dst_ptr = dst_buffer[offset_y] | ||
630 | - [comp_width - dst_blk_x - offset_x - 1]; | ||
631 | + src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] | ||
632 | + [dst_blk_y + offset_y + y_crop_blocks]; | ||
633 | for (i = 0; i < DCTSIZE; i++) { | ||
634 | for (j = 0; j < DCTSIZE; j++) | ||
635 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
636 | @@ -277,7 +433,8 @@ | ||
637 | } | ||
638 | } else { | ||
639 | /* Edge blocks are transposed but not mirrored. */ | ||
640 | - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
641 | + src_ptr = src_buffer[offset_x] | ||
642 | + [dst_blk_y + offset_y + y_crop_blocks]; | ||
643 | for (i = 0; i < DCTSIZE; i++) | ||
644 | for (j = 0; j < DCTSIZE; j++) | ||
645 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
646 | @@ -292,6 +449,7 @@ | ||
647 | |||
648 | LOCAL(void) | ||
649 | do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
650 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
651 | jvirt_barray_ptr *src_coef_arrays, | ||
652 | jvirt_barray_ptr *dst_coef_arrays) | ||
653 | /* 270 degree rotation is equivalent to | ||
654 | @@ -301,6 +459,7 @@ | ||
655 | */ | ||
656 | { | ||
657 | JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; | ||
658 | + JDIMENSION x_crop_blocks, y_crop_blocks; | ||
659 | int ci, i, j, offset_x, offset_y; | ||
660 | JBLOCKARRAY src_buffer, dst_buffer; | ||
661 | JCOEFPTR src_ptr, dst_ptr; | ||
662 | @@ -310,11 +469,13 @@ | ||
663 | * at the (output) bottom edge properly. They just get transposed and | ||
664 | * not mirrored. | ||
665 | */ | ||
666 | - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
667 | + MCU_rows = srcinfo->image_width / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
668 | |||
669 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
670 | compptr = dstinfo->comp_info + ci; | ||
671 | comp_height = MCU_rows * compptr->v_samp_factor; | ||
672 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
673 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
674 | for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
675 | dst_blk_y += compptr->v_samp_factor) { | ||
676 | dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
677 | @@ -324,14 +485,15 @@ | ||
678 | for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; | ||
679 | dst_blk_x += compptr->h_samp_factor) { | ||
680 | src_buffer = (*srcinfo->mem->access_virt_barray) | ||
681 | - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, | ||
682 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
683 | + dst_blk_x + x_crop_blocks, | ||
684 | (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
685 | for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { | ||
686 | dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
687 | - if (dst_blk_y < comp_height) { | ||
688 | + if (y_crop_blocks + dst_blk_y < comp_height) { | ||
689 | /* Block is within the mirrorable area. */ | ||
690 | src_ptr = src_buffer[offset_x] | ||
691 | - [comp_height - dst_blk_y - offset_y - 1]; | ||
692 | + [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; | ||
693 | for (i = 0; i < DCTSIZE; i++) { | ||
694 | for (j = 0; j < DCTSIZE; j++) { | ||
695 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
696 | @@ -341,7 +503,8 @@ | ||
697 | } | ||
698 | } else { | ||
699 | /* Edge blocks are transposed but not mirrored. */ | ||
700 | - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; | ||
701 | + src_ptr = src_buffer[offset_x] | ||
702 | + [dst_blk_y + offset_y + y_crop_blocks]; | ||
703 | for (i = 0; i < DCTSIZE; i++) | ||
704 | for (j = 0; j < DCTSIZE; j++) | ||
705 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
706 | @@ -356,6 +519,7 @@ | ||
707 | |||
708 | LOCAL(void) | ||
709 | do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
710 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
711 | jvirt_barray_ptr *src_coef_arrays, | ||
712 | jvirt_barray_ptr *dst_coef_arrays) | ||
713 | /* 180 degree rotation is equivalent to | ||
714 | @@ -365,89 +529,93 @@ | ||
715 | */ | ||
716 | { | ||
717 | JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; | ||
718 | + JDIMENSION x_crop_blocks, y_crop_blocks; | ||
719 | int ci, i, j, offset_y; | ||
720 | JBLOCKARRAY src_buffer, dst_buffer; | ||
721 | JBLOCKROW src_row_ptr, dst_row_ptr; | ||
722 | JCOEFPTR src_ptr, dst_ptr; | ||
723 | jpeg_component_info *compptr; | ||
724 | |||
725 | - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
726 | - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
727 | + MCU_cols = srcinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
728 | + MCU_rows = srcinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
729 | |||
730 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
731 | compptr = dstinfo->comp_info + ci; | ||
732 | comp_width = MCU_cols * compptr->h_samp_factor; | ||
733 | comp_height = MCU_rows * compptr->v_samp_factor; | ||
734 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
735 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
736 | for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
737 | dst_blk_y += compptr->v_samp_factor) { | ||
738 | dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
739 | ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, | ||
740 | (JDIMENSION) compptr->v_samp_factor, TRUE); | ||
741 | - if (dst_blk_y < comp_height) { | ||
742 | + if (y_crop_blocks + dst_blk_y < comp_height) { | ||
743 | /* Row is within the vertically mirrorable area. */ | ||
744 | src_buffer = (*srcinfo->mem->access_virt_barray) | ||
745 | ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
746 | - comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor, | ||
747 | + comp_height - y_crop_blocks - dst_blk_y - | ||
748 | + (JDIMENSION) compptr->v_samp_factor, | ||
749 | (JDIMENSION) compptr->v_samp_factor, FALSE); | ||
750 | } else { | ||
751 | /* Bottom-edge rows are only mirrored horizontally. */ | ||
752 | src_buffer = (*srcinfo->mem->access_virt_barray) | ||
753 | - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y, | ||
754 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
755 | + dst_blk_y + y_crop_blocks, | ||
756 | (JDIMENSION) compptr->v_samp_factor, FALSE); | ||
757 | } | ||
758 | for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
759 | - if (dst_blk_y < comp_height) { | ||
760 | + dst_row_ptr = dst_buffer[offset_y]; | ||
761 | + if (y_crop_blocks + dst_blk_y < comp_height) { | ||
762 | /* Row is within the mirrorable area. */ | ||
763 | - dst_row_ptr = dst_buffer[offset_y]; | ||
764 | src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; | ||
765 | - /* Process the blocks that can be mirrored both ways. */ | ||
766 | - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { | ||
767 | + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { | ||
768 | dst_ptr = dst_row_ptr[dst_blk_x]; | ||
769 | - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; | ||
770 | - for (i = 0; i < DCTSIZE; i += 2) { | ||
771 | - /* For even row, negate every odd column. */ | ||
772 | - for (j = 0; j < DCTSIZE; j += 2) { | ||
773 | - *dst_ptr++ = *src_ptr++; | ||
774 | - *dst_ptr++ = - *src_ptr++; | ||
775 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
776 | + /* Process the blocks that can be mirrored both ways. */ | ||
777 | + src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; | ||
778 | + for (i = 0; i < DCTSIZE; i += 2) { | ||
779 | + /* For even row, negate every odd column. */ | ||
780 | + for (j = 0; j < DCTSIZE; j += 2) { | ||
781 | + *dst_ptr++ = *src_ptr++; | ||
782 | + *dst_ptr++ = - *src_ptr++; | ||
783 | + } | ||
784 | + /* For odd row, negate every even column. */ | ||
785 | + for (j = 0; j < DCTSIZE; j += 2) { | ||
786 | + *dst_ptr++ = - *src_ptr++; | ||
787 | + *dst_ptr++ = *src_ptr++; | ||
788 | + } | ||
789 | } | ||
790 | - /* For odd row, negate every even column. */ | ||
791 | - for (j = 0; j < DCTSIZE; j += 2) { | ||
792 | - *dst_ptr++ = - *src_ptr++; | ||
793 | - *dst_ptr++ = *src_ptr++; | ||
794 | + } else { | ||
795 | + /* Any remaining right-edge blocks are only mirrored vertically. */ | ||
796 | + src_ptr = src_row_ptr[x_crop_blocks + dst_blk_x]; | ||
797 | + for (i = 0; i < DCTSIZE; i += 2) { | ||
798 | + for (j = 0; j < DCTSIZE; j++) | ||
799 | + *dst_ptr++ = *src_ptr++; | ||
800 | + for (j = 0; j < DCTSIZE; j++) | ||
801 | + *dst_ptr++ = - *src_ptr++; | ||
802 | } | ||
803 | } | ||
804 | } | ||
805 | - /* Any remaining right-edge blocks are only mirrored vertically. */ | ||
806 | - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { | ||
807 | - dst_ptr = dst_row_ptr[dst_blk_x]; | ||
808 | - src_ptr = src_row_ptr[dst_blk_x]; | ||
809 | - for (i = 0; i < DCTSIZE; i += 2) { | ||
810 | - for (j = 0; j < DCTSIZE; j++) | ||
811 | - *dst_ptr++ = *src_ptr++; | ||
812 | - for (j = 0; j < DCTSIZE; j++) | ||
813 | - *dst_ptr++ = - *src_ptr++; | ||
814 | - } | ||
815 | - } | ||
816 | } else { | ||
817 | /* Remaining rows are just mirrored horizontally. */ | ||
818 | - dst_row_ptr = dst_buffer[offset_y]; | ||
819 | src_row_ptr = src_buffer[offset_y]; | ||
820 | - /* Process the blocks that can be mirrored. */ | ||
821 | - for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) { | ||
822 | - dst_ptr = dst_row_ptr[dst_blk_x]; | ||
823 | - src_ptr = src_row_ptr[comp_width - dst_blk_x - 1]; | ||
824 | - for (i = 0; i < DCTSIZE2; i += 2) { | ||
825 | - *dst_ptr++ = *src_ptr++; | ||
826 | - *dst_ptr++ = - *src_ptr++; | ||
827 | + for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { | ||
828 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
829 | + /* Process the blocks that can be mirrored. */ | ||
830 | + dst_ptr = dst_row_ptr[dst_blk_x]; | ||
831 | + src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; | ||
832 | + for (i = 0; i < DCTSIZE2; i += 2) { | ||
833 | + *dst_ptr++ = *src_ptr++; | ||
834 | + *dst_ptr++ = - *src_ptr++; | ||
835 | + } | ||
836 | + } else { | ||
837 | + /* Any remaining right-edge blocks are only copied. */ | ||
838 | + jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, | ||
839 | + dst_row_ptr + dst_blk_x, | ||
840 | + (JDIMENSION) 1); | ||
841 | } | ||
842 | } | ||
843 | - /* Any remaining right-edge blocks are only copied. */ | ||
844 | - for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { | ||
845 | - dst_ptr = dst_row_ptr[dst_blk_x]; | ||
846 | - src_ptr = src_row_ptr[dst_blk_x]; | ||
847 | - for (i = 0; i < DCTSIZE2; i++) | ||
848 | - *dst_ptr++ = *src_ptr++; | ||
849 | - } | ||
850 | } | ||
851 | } | ||
852 | } | ||
853 | @@ -457,6 +625,7 @@ | ||
854 | |||
855 | LOCAL(void) | ||
856 | do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
857 | + JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, | ||
858 | jvirt_barray_ptr *src_coef_arrays, | ||
859 | jvirt_barray_ptr *dst_coef_arrays) | ||
860 | /* Transverse transpose is equivalent to | ||
861 | @@ -470,18 +639,21 @@ | ||
862 | */ | ||
863 | { | ||
864 | JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; | ||
865 | + JDIMENSION x_crop_blocks, y_crop_blocks; | ||
866 | int ci, i, j, offset_x, offset_y; | ||
867 | JBLOCKARRAY src_buffer, dst_buffer; | ||
868 | JCOEFPTR src_ptr, dst_ptr; | ||
869 | jpeg_component_info *compptr; | ||
870 | |||
871 | - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
872 | - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
873 | + MCU_cols = srcinfo->image_height / (dstinfo->max_h_samp_factor * DCTSIZE); | ||
874 | + MCU_rows = srcinfo->image_width / (dstinfo->max_v_samp_factor * DCTSIZE); | ||
875 | |||
876 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
877 | compptr = dstinfo->comp_info + ci; | ||
878 | comp_width = MCU_cols * compptr->h_samp_factor; | ||
879 | comp_height = MCU_rows * compptr->v_samp_factor; | ||
880 | + x_crop_blocks = x_crop_offset * compptr->h_samp_factor; | ||
881 | + y_crop_blocks = y_crop_offset * compptr->v_samp_factor; | ||
882 | for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; | ||
883 | dst_blk_y += compptr->v_samp_factor) { | ||
884 | dst_buffer = (*srcinfo->mem->access_virt_barray) | ||
885 | @@ -490,17 +662,26 @@ | ||
886 | for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { | ||
887 | for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; | ||
888 | dst_blk_x += compptr->h_samp_factor) { | ||
889 | - src_buffer = (*srcinfo->mem->access_virt_barray) | ||
890 | - ((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x, | ||
891 | - (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
892 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
893 | + /* Block is within the mirrorable area. */ | ||
894 | + src_buffer = (*srcinfo->mem->access_virt_barray) | ||
895 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
896 | + comp_width - x_crop_blocks - dst_blk_x - | ||
897 | + (JDIMENSION) compptr->h_samp_factor, | ||
898 | + (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
899 | + } else { | ||
900 | + src_buffer = (*srcinfo->mem->access_virt_barray) | ||
901 | + ((j_common_ptr) srcinfo, src_coef_arrays[ci], | ||
902 | + dst_blk_x + x_crop_blocks, | ||
903 | + (JDIMENSION) compptr->h_samp_factor, FALSE); | ||
904 | + } | ||
905 | for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { | ||
906 | - if (dst_blk_y < comp_height) { | ||
907 | - src_ptr = src_buffer[offset_x] | ||
908 | - [comp_height - dst_blk_y - offset_y - 1]; | ||
909 | - if (dst_blk_x < comp_width) { | ||
910 | + dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
911 | + if (y_crop_blocks + dst_blk_y < comp_height) { | ||
912 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
913 | /* Block is within the mirrorable area. */ | ||
914 | - dst_ptr = dst_buffer[offset_y] | ||
915 | - [comp_width - dst_blk_x - offset_x - 1]; | ||
916 | + src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] | ||
917 | + [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; | ||
918 | for (i = 0; i < DCTSIZE; i++) { | ||
919 | for (j = 0; j < DCTSIZE; j++) { | ||
920 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
921 | @@ -516,7 +697,8 @@ | ||
922 | } | ||
923 | } else { | ||
924 | /* Right-edge blocks are mirrored in y only */ | ||
925 | - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
926 | + src_ptr = src_buffer[offset_x] | ||
927 | + [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; | ||
928 | for (i = 0; i < DCTSIZE; i++) { | ||
929 | for (j = 0; j < DCTSIZE; j++) { | ||
930 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
931 | @@ -526,11 +708,10 @@ | ||
932 | } | ||
933 | } | ||
934 | } else { | ||
935 | - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y]; | ||
936 | - if (dst_blk_x < comp_width) { | ||
937 | + if (x_crop_blocks + dst_blk_x < comp_width) { | ||
938 | /* Bottom-edge blocks are mirrored in x only */ | ||
939 | - dst_ptr = dst_buffer[offset_y] | ||
940 | - [comp_width - dst_blk_x - offset_x - 1]; | ||
941 | + src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] | ||
942 | + [dst_blk_y + offset_y + y_crop_blocks]; | ||
943 | for (i = 0; i < DCTSIZE; i++) { | ||
944 | for (j = 0; j < DCTSIZE; j++) | ||
945 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
946 | @@ -540,7 +721,8 @@ | ||
947 | } | ||
948 | } else { | ||
949 | /* At lower right corner, just transpose, no mirroring */ | ||
950 | - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; | ||
951 | + src_ptr = src_buffer[offset_x] | ||
952 | + [dst_blk_y + offset_y + y_crop_blocks]; | ||
953 | for (i = 0; i < DCTSIZE; i++) | ||
954 | for (j = 0; j < DCTSIZE; j++) | ||
955 | dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; | ||
956 | @@ -554,8 +736,116 @@ | ||
957 | } | ||
958 | |||
959 | |||
960 | +/* Parse an unsigned integer: subroutine for jtransform_parse_crop_spec. | ||
961 | + * Returns TRUE if valid integer found, FALSE if not. | ||
962 | + * *strptr is advanced over the digit string, and *result is set to its value. | ||
963 | + */ | ||
964 | + | ||
965 | +LOCAL(boolean) | ||
966 | +jt_read_integer (const char ** strptr, JDIMENSION * result) | ||
967 | +{ | ||
968 | + const char * ptr = *strptr; | ||
969 | + JDIMENSION val = 0; | ||
970 | + | ||
971 | + for (; isdigit(*ptr); ptr++) { | ||
972 | + val = val * 10 + (JDIMENSION) (*ptr - '0'); | ||
973 | + } | ||
974 | + *result = val; | ||
975 | + if (ptr == *strptr) | ||
976 | + return FALSE; /* oops, no digits */ | ||
977 | + *strptr = ptr; | ||
978 | + return TRUE; | ||
979 | +} | ||
980 | + | ||
981 | + | ||
982 | +/* Parse a crop specification (written in X11 geometry style). | ||
983 | + * The routine returns TRUE if the spec string is valid, FALSE if not. | ||
984 | + * | ||
985 | + * The crop spec string should have the format | ||
986 | + * <width>x<height>{+-}<xoffset>{+-}<yoffset> | ||
987 | + * where width, height, xoffset, and yoffset are unsigned integers. | ||
988 | + * Each of the elements can be omitted to indicate a default value. | ||
989 | + * (A weakness of this style is that it is not possible to omit xoffset | ||
990 | + * while specifying yoffset, since they look alike.) | ||
991 | + * | ||
992 | + * This code is loosely based on XParseGeometry from the X11 distribution. | ||
993 | + */ | ||
994 | + | ||
995 | +GLOBAL(boolean) | ||
996 | +jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec) | ||
997 | +{ | ||
998 | + info->crop = FALSE; | ||
999 | + info->crop_width_set = JCROP_UNSET; | ||
1000 | + info->crop_height_set = JCROP_UNSET; | ||
1001 | + info->crop_xoffset_set = JCROP_UNSET; | ||
1002 | + info->crop_yoffset_set = JCROP_UNSET; | ||
1003 | + | ||
1004 | + if (isdigit(*spec)) { | ||
1005 | + /* fetch width */ | ||
1006 | + if (! jt_read_integer(&spec, &info->crop_width)) | ||
1007 | + return FALSE; | ||
1008 | + info->crop_width_set = JCROP_POS; | ||
1009 | + } | ||
1010 | + if (*spec == 'x' || *spec == 'X') { | ||
1011 | + /* fetch height */ | ||
1012 | + spec++; | ||
1013 | + if (! jt_read_integer(&spec, &info->crop_height)) | ||
1014 | + return FALSE; | ||
1015 | + info->crop_height_set = JCROP_POS; | ||
1016 | + } | ||
1017 | + if (*spec == '+' || *spec == '-') { | ||
1018 | + /* fetch xoffset */ | ||
1019 | + info->crop_xoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; | ||
1020 | + spec++; | ||
1021 | + if (! jt_read_integer(&spec, &info->crop_xoffset)) | ||
1022 | + return FALSE; | ||
1023 | + } | ||
1024 | + if (*spec == '+' || *spec == '-') { | ||
1025 | + /* fetch yoffset */ | ||
1026 | + info->crop_yoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; | ||
1027 | + spec++; | ||
1028 | + if (! jt_read_integer(&spec, &info->crop_yoffset)) | ||
1029 | + return FALSE; | ||
1030 | + } | ||
1031 | + /* We had better have gotten to the end of the string. */ | ||
1032 | + if (*spec != '\0') | ||
1033 | + return FALSE; | ||
1034 | + info->crop = TRUE; | ||
1035 | + return TRUE; | ||
1036 | +} | ||
1037 | + | ||
1038 | + | ||
1039 | +/* Trim off any partial iMCUs on the indicated destination edge */ | ||
1040 | + | ||
1041 | +LOCAL(void) | ||
1042 | +trim_right_edge (jpeg_transform_info *info, JDIMENSION full_width) | ||
1043 | +{ | ||
1044 | + JDIMENSION MCU_cols; | ||
1045 | + | ||
1046 | + MCU_cols = info->output_width / (info->max_h_samp_factor * DCTSIZE); | ||
1047 | + if (MCU_cols > 0 && info->x_crop_offset + MCU_cols == | ||
1048 | + full_width / (info->max_h_samp_factor * DCTSIZE)) | ||
1049 | + info->output_width = MCU_cols * (info->max_h_samp_factor * DCTSIZE); | ||
1050 | +} | ||
1051 | + | ||
1052 | +LOCAL(void) | ||
1053 | +trim_bottom_edge (jpeg_transform_info *info, JDIMENSION full_height) | ||
1054 | +{ | ||
1055 | + JDIMENSION MCU_rows; | ||
1056 | + | ||
1057 | + MCU_rows = info->output_height / (info->max_v_samp_factor * DCTSIZE); | ||
1058 | + if (MCU_rows > 0 && info->y_crop_offset + MCU_rows == | ||
1059 | + full_height / (info->max_v_samp_factor * DCTSIZE)) | ||
1060 | + info->output_height = MCU_rows * (info->max_v_samp_factor * DCTSIZE); | ||
1061 | +} | ||
1062 | + | ||
1063 | + | ||
1064 | /* Request any required workspace. | ||
1065 | * | ||
1066 | + * This routine figures out the size that the output image will be | ||
1067 | + * (which implies that all the transform parameters must be set before | ||
1068 | + * it is called). | ||
1069 | + * | ||
1070 | * We allocate the workspace virtual arrays from the source decompression | ||
1071 | * object, so that all the arrays (both the original data and the workspace) | ||
1072 | * will be taken into account while making memory management decisions. | ||
1073 | @@ -569,9 +859,13 @@ | ||
1074 | jpeg_transform_info *info) | ||
1075 | { | ||
1076 | jvirt_barray_ptr *coef_arrays = NULL; | ||
1077 | + boolean need_workspace, transpose_it; | ||
1078 | jpeg_component_info *compptr; | ||
1079 | - int ci; | ||
1080 | + JDIMENSION xoffset, yoffset, width_in_iMCUs, height_in_iMCUs; | ||
1081 | + JDIMENSION width_in_blocks, height_in_blocks; | ||
1082 | + int ci, h_samp_factor, v_samp_factor; | ||
1083 | |||
1084 | + /* Determine number of components in output image */ | ||
1085 | if (info->force_grayscale && | ||
1086 | srcinfo->jpeg_color_space == JCS_YCbCr && | ||
1087 | srcinfo->num_components == 3) { | ||
1088 | @@ -581,55 +875,181 @@ | ||
1089 | /* Process all the components */ | ||
1090 | info->num_components = srcinfo->num_components; | ||
1091 | } | ||
1092 | + /* If there is only one output component, force the iMCU size to be 1; | ||
1093 | + * else use the source iMCU size. (This allows us to do the right thing | ||
1094 | + * when reducing color to grayscale, and also provides a handy way of | ||
1095 | + * cleaning up "funny" grayscale images whose sampling factors are not 1x1.) | ||
1096 | + */ | ||
1097 | + | ||
1098 | + switch (info->transform) { | ||
1099 | + case JXFORM_TRANSPOSE: | ||
1100 | + case JXFORM_TRANSVERSE: | ||
1101 | + case JXFORM_ROT_90: | ||
1102 | + case JXFORM_ROT_270: | ||
1103 | + info->output_width = srcinfo->image_height; | ||
1104 | + info->output_height = srcinfo->image_width; | ||
1105 | + if (info->num_components == 1) { | ||
1106 | + info->max_h_samp_factor = 1; | ||
1107 | + info->max_v_samp_factor = 1; | ||
1108 | + } else { | ||
1109 | + info->max_h_samp_factor = srcinfo->max_v_samp_factor; | ||
1110 | + info->max_v_samp_factor = srcinfo->max_h_samp_factor; | ||
1111 | + } | ||
1112 | + break; | ||
1113 | + default: | ||
1114 | + info->output_width = srcinfo->image_width; | ||
1115 | + info->output_height = srcinfo->image_height; | ||
1116 | + if (info->num_components == 1) { | ||
1117 | + info->max_h_samp_factor = 1; | ||
1118 | + info->max_v_samp_factor = 1; | ||
1119 | + } else { | ||
1120 | + info->max_h_samp_factor = srcinfo->max_h_samp_factor; | ||
1121 | + info->max_v_samp_factor = srcinfo->max_v_samp_factor; | ||
1122 | + } | ||
1123 | + break; | ||
1124 | + } | ||
1125 | + | ||
1126 | + /* If cropping has been requested, compute the crop area's position and | ||
1127 | + * dimensions, ensuring that its upper left corner falls at an iMCU boundary. | ||
1128 | + */ | ||
1129 | + if (info->crop) { | ||
1130 | + /* Insert default values for unset crop parameters */ | ||
1131 | + if (info->crop_xoffset_set == JCROP_UNSET) | ||
1132 | + info->crop_xoffset = 0; /* default to +0 */ | ||
1133 | + if (info->crop_yoffset_set == JCROP_UNSET) | ||
1134 | + info->crop_yoffset = 0; /* default to +0 */ | ||
1135 | + if (info->crop_xoffset >= info->output_width || | ||
1136 | + info->crop_yoffset >= info->output_height) | ||
1137 | + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); | ||
1138 | + if (info->crop_width_set == JCROP_UNSET) | ||
1139 | + info->crop_width = info->output_width - info->crop_xoffset; | ||
1140 | + if (info->crop_height_set == JCROP_UNSET) | ||
1141 | + info->crop_height = info->output_height - info->crop_yoffset; | ||
1142 | + /* Ensure parameters are valid */ | ||
1143 | + if (info->crop_width <= 0 || info->crop_width > info->output_width || | ||
1144 | + info->crop_height <= 0 || info->crop_height > info->output_height || | ||
1145 | + info->crop_xoffset > info->output_width - info->crop_width || | ||
1146 | + info->crop_yoffset > info->output_height - info->crop_height) | ||
1147 | + ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); | ||
1148 | + /* Convert negative crop offsets into regular offsets */ | ||
1149 | + if (info->crop_xoffset_set == JCROP_NEG) | ||
1150 | + xoffset = info->output_width - info->crop_width - info->crop_xoffset; | ||
1151 | + else | ||
1152 | + xoffset = info->crop_xoffset; | ||
1153 | + if (info->crop_yoffset_set == JCROP_NEG) | ||
1154 | + yoffset = info->output_height - info->crop_height - info->crop_yoffset; | ||
1155 | + else | ||
1156 | + yoffset = info->crop_yoffset; | ||
1157 | + /* Now adjust so that upper left corner falls at an iMCU boundary */ | ||
1158 | + info->output_width = | ||
1159 | + info->crop_width + (xoffset % (info->max_h_samp_factor * DCTSIZE)); | ||
1160 | + info->output_height = | ||
1161 | + info->crop_height + (yoffset % (info->max_v_samp_factor * DCTSIZE)); | ||
1162 | + /* Save x/y offsets measured in iMCUs */ | ||
1163 | + info->x_crop_offset = xoffset / (info->max_h_samp_factor * DCTSIZE); | ||
1164 | + info->y_crop_offset = yoffset / (info->max_v_samp_factor * DCTSIZE); | ||
1165 | + } else { | ||
1166 | + info->x_crop_offset = 0; | ||
1167 | + info->y_crop_offset = 0; | ||
1168 | + } | ||
1169 | |||
1170 | + /* Figure out whether we need workspace arrays, | ||
1171 | + * and if so whether they are transposed relative to the source. | ||
1172 | + */ | ||
1173 | + need_workspace = FALSE; | ||
1174 | + transpose_it = FALSE; | ||
1175 | switch (info->transform) { | ||
1176 | case JXFORM_NONE: | ||
1177 | + if (info->x_crop_offset != 0 || info->y_crop_offset != 0) | ||
1178 | + need_workspace = TRUE; | ||
1179 | + /* No workspace needed if neither cropping nor transforming */ | ||
1180 | + break; | ||
1181 | case JXFORM_FLIP_H: | ||
1182 | - /* Don't need a workspace array */ | ||
1183 | + if (info->trim) | ||
1184 | + trim_right_edge(info, srcinfo->image_width); | ||
1185 | + if (info->y_crop_offset != 0) | ||
1186 | + need_workspace = TRUE; | ||
1187 | + /* do_flip_h_no_crop doesn't need a workspace array */ | ||
1188 | break; | ||
1189 | case JXFORM_FLIP_V: | ||
1190 | - case JXFORM_ROT_180: | ||
1191 | - /* Need workspace arrays having same dimensions as source image. | ||
1192 | - * Note that we allocate arrays padded out to the next iMCU boundary, | ||
1193 | - * so that transform routines need not worry about missing edge blocks. | ||
1194 | - */ | ||
1195 | - coef_arrays = (jvirt_barray_ptr *) | ||
1196 | - (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, | ||
1197 | - SIZEOF(jvirt_barray_ptr) * info->num_components); | ||
1198 | - for (ci = 0; ci < info->num_components; ci++) { | ||
1199 | - compptr = srcinfo->comp_info + ci; | ||
1200 | - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) | ||
1201 | - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, | ||
1202 | - (JDIMENSION) jround_up((long) compptr->width_in_blocks, | ||
1203 | - (long) compptr->h_samp_factor), | ||
1204 | - (JDIMENSION) jround_up((long) compptr->height_in_blocks, | ||
1205 | - (long) compptr->v_samp_factor), | ||
1206 | - (JDIMENSION) compptr->v_samp_factor); | ||
1207 | - } | ||
1208 | + if (info->trim) | ||
1209 | + trim_bottom_edge(info, srcinfo->image_height); | ||
1210 | + /* Need workspace arrays having same dimensions as source image. */ | ||
1211 | + need_workspace = TRUE; | ||
1212 | break; | ||
1213 | case JXFORM_TRANSPOSE: | ||
1214 | + /* transpose does NOT have to trim anything */ | ||
1215 | + /* Need workspace arrays having transposed dimensions. */ | ||
1216 | + need_workspace = TRUE; | ||
1217 | + transpose_it = TRUE; | ||
1218 | + break; | ||
1219 | case JXFORM_TRANSVERSE: | ||
1220 | + if (info->trim) { | ||
1221 | + trim_right_edge(info, srcinfo->image_height); | ||
1222 | + trim_bottom_edge(info, srcinfo->image_width); | ||
1223 | + } | ||
1224 | + /* Need workspace arrays having transposed dimensions. */ | ||
1225 | + need_workspace = TRUE; | ||
1226 | + transpose_it = TRUE; | ||
1227 | + break; | ||
1228 | case JXFORM_ROT_90: | ||
1229 | + if (info->trim) | ||
1230 | + trim_right_edge(info, srcinfo->image_height); | ||
1231 | + /* Need workspace arrays having transposed dimensions. */ | ||
1232 | + need_workspace = TRUE; | ||
1233 | + transpose_it = TRUE; | ||
1234 | + break; | ||
1235 | + case JXFORM_ROT_180: | ||
1236 | + if (info->trim) { | ||
1237 | + trim_right_edge(info, srcinfo->image_width); | ||
1238 | + trim_bottom_edge(info, srcinfo->image_height); | ||
1239 | + } | ||
1240 | + /* Need workspace arrays having same dimensions as source image. */ | ||
1241 | + need_workspace = TRUE; | ||
1242 | + break; | ||
1243 | case JXFORM_ROT_270: | ||
1244 | - /* Need workspace arrays having transposed dimensions. | ||
1245 | - * Note that we allocate arrays padded out to the next iMCU boundary, | ||
1246 | - * so that transform routines need not worry about missing edge blocks. | ||
1247 | - */ | ||
1248 | + if (info->trim) | ||
1249 | + trim_bottom_edge(info, srcinfo->image_width); | ||
1250 | + /* Need workspace arrays having transposed dimensions. */ | ||
1251 | + need_workspace = TRUE; | ||
1252 | + transpose_it = TRUE; | ||
1253 | + break; | ||
1254 | + } | ||
1255 | + | ||
1256 | + /* Allocate workspace if needed. | ||
1257 | + * Note that we allocate arrays padded out to the next iMCU boundary, | ||
1258 | + * so that transform routines need not worry about missing edge blocks. | ||
1259 | + */ | ||
1260 | + if (need_workspace) { | ||
1261 | coef_arrays = (jvirt_barray_ptr *) | ||
1262 | (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, | ||
1263 | - SIZEOF(jvirt_barray_ptr) * info->num_components); | ||
1264 | + SIZEOF(jvirt_barray_ptr) * info->num_components); | ||
1265 | + width_in_iMCUs = (JDIMENSION) | ||
1266 | + jdiv_round_up((long) info->output_width, | ||
1267 | + (long) (info->max_h_samp_factor * DCTSIZE)); | ||
1268 | + height_in_iMCUs = (JDIMENSION) | ||
1269 | + jdiv_round_up((long) info->output_height, | ||
1270 | + (long) (info->max_v_samp_factor * DCTSIZE)); | ||
1271 | for (ci = 0; ci < info->num_components; ci++) { | ||
1272 | compptr = srcinfo->comp_info + ci; | ||
1273 | + if (info->num_components == 1) { | ||
1274 | + /* we're going to force samp factors to 1x1 in this case */ | ||
1275 | + h_samp_factor = v_samp_factor = 1; | ||
1276 | + } else if (transpose_it) { | ||
1277 | + h_samp_factor = compptr->v_samp_factor; | ||
1278 | + v_samp_factor = compptr->h_samp_factor; | ||
1279 | + } else { | ||
1280 | + h_samp_factor = compptr->h_samp_factor; | ||
1281 | + v_samp_factor = compptr->v_samp_factor; | ||
1282 | + } | ||
1283 | + width_in_blocks = width_in_iMCUs * h_samp_factor; | ||
1284 | + height_in_blocks = height_in_iMCUs * v_samp_factor; | ||
1285 | coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) | ||
1286 | ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, | ||
1287 | - (JDIMENSION) jround_up((long) compptr->height_in_blocks, | ||
1288 | - (long) compptr->v_samp_factor), | ||
1289 | - (JDIMENSION) jround_up((long) compptr->width_in_blocks, | ||
1290 | - (long) compptr->h_samp_factor), | ||
1291 | - (JDIMENSION) compptr->h_samp_factor); | ||
1292 | + width_in_blocks, height_in_blocks, (JDIMENSION) v_samp_factor); | ||
1293 | } | ||
1294 | - break; | ||
1295 | } | ||
1296 | + | ||
1297 | info->workspace_coef_arrays = coef_arrays; | ||
1298 | } | ||
1299 | |||
1300 | @@ -642,14 +1062,8 @@ | ||
1301 | int tblno, i, j, ci, itemp; | ||
1302 | jpeg_component_info *compptr; | ||
1303 | JQUANT_TBL *qtblptr; | ||
1304 | - JDIMENSION dtemp; | ||
1305 | UINT16 qtemp; | ||
1306 | |||
1307 | - /* Transpose basic image dimensions */ | ||
1308 | - dtemp = dstinfo->image_width; | ||
1309 | - dstinfo->image_width = dstinfo->image_height; | ||
1310 | - dstinfo->image_height = dtemp; | ||
1311 | - | ||
1312 | /* Transpose sampling factors */ | ||
1313 | for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
1314 | compptr = dstinfo->comp_info + ci; | ||
1315 | @@ -674,46 +1088,159 @@ | ||
1316 | } | ||
1317 | |||
1318 | |||
1319 | -/* Trim off any partial iMCUs on the indicated destination edge */ | ||
1320 | +/* Adjust Exif image parameters. | ||
1321 | + * | ||
1322 | + * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible. | ||
1323 | + */ | ||
1324 | |||
1325 | LOCAL(void) | ||
1326 | -trim_right_edge (j_compress_ptr dstinfo) | ||
1327 | +adjust_exif_parameters (JOCTET FAR * data, unsigned int length, | ||
1328 | + JDIMENSION new_width, JDIMENSION new_height) | ||
1329 | { | ||
1330 | - int ci, max_h_samp_factor; | ||
1331 | - JDIMENSION MCU_cols; | ||
1332 | + boolean is_motorola; /* Flag for byte order */ | ||
1333 | + unsigned int number_of_tags, tagnum; | ||
1334 | + unsigned int firstoffset, offset; | ||
1335 | + JDIMENSION new_value; | ||
1336 | |||
1337 | - /* We have to compute max_h_samp_factor ourselves, | ||
1338 | - * because it hasn't been set yet in the destination | ||
1339 | - * (and we don't want to use the source's value). | ||
1340 | - */ | ||
1341 | - max_h_samp_factor = 1; | ||
1342 | - for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
1343 | - int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; | ||
1344 | - max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); | ||
1345 | + if (length < 12) return; /* Length of an IFD entry */ | ||
1346 | + | ||
1347 | + /* Discover byte order */ | ||
1348 | + if (GETJOCTET(data[0]) == 0x49 && GETJOCTET(data[1]) == 0x49) | ||
1349 | + is_motorola = FALSE; | ||
1350 | + else if (GETJOCTET(data[0]) == 0x4D && GETJOCTET(data[1]) == 0x4D) | ||
1351 | + is_motorola = TRUE; | ||
1352 | + else | ||
1353 | + return; | ||
1354 | + | ||
1355 | + /* Check Tag Mark */ | ||
1356 | + if (is_motorola) { | ||
1357 | + if (GETJOCTET(data[2]) != 0) return; | ||
1358 | + if (GETJOCTET(data[3]) != 0x2A) return; | ||
1359 | + } else { | ||
1360 | + if (GETJOCTET(data[3]) != 0) return; | ||
1361 | + if (GETJOCTET(data[2]) != 0x2A) return; | ||
1362 | } | ||
1363 | - MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); | ||
1364 | - if (MCU_cols > 0) /* can't trim to 0 pixels */ | ||
1365 | - dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); | ||
1366 | -} | ||
1367 | |||
1368 | -LOCAL(void) | ||
1369 | -trim_bottom_edge (j_compress_ptr dstinfo) | ||
1370 | -{ | ||
1371 | - int ci, max_v_samp_factor; | ||
1372 | - JDIMENSION MCU_rows; | ||
1373 | + /* Get first IFD offset (offset to IFD0) */ | ||
1374 | + if (is_motorola) { | ||
1375 | + if (GETJOCTET(data[4]) != 0) return; | ||
1376 | + if (GETJOCTET(data[5]) != 0) return; | ||
1377 | + firstoffset = GETJOCTET(data[6]); | ||
1378 | + firstoffset <<= 8; | ||
1379 | + firstoffset += GETJOCTET(data[7]); | ||
1380 | + } else { | ||
1381 | + if (GETJOCTET(data[7]) != 0) return; | ||
1382 | + if (GETJOCTET(data[6]) != 0) return; | ||
1383 | + firstoffset = GETJOCTET(data[5]); | ||
1384 | + firstoffset <<= 8; | ||
1385 | + firstoffset += GETJOCTET(data[4]); | ||
1386 | + } | ||
1387 | + if (firstoffset > length - 2) return; /* check end of data segment */ | ||
1388 | |||
1389 | - /* We have to compute max_v_samp_factor ourselves, | ||
1390 | - * because it hasn't been set yet in the destination | ||
1391 | - * (and we don't want to use the source's value). | ||
1392 | - */ | ||
1393 | - max_v_samp_factor = 1; | ||
1394 | - for (ci = 0; ci < dstinfo->num_components; ci++) { | ||
1395 | - int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; | ||
1396 | - max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); | ||
1397 | + /* Get the number of directory entries contained in this IFD */ | ||
1398 | + if (is_motorola) { | ||
1399 | + number_of_tags = GETJOCTET(data[firstoffset]); | ||
1400 | + number_of_tags <<= 8; | ||
1401 | + number_of_tags += GETJOCTET(data[firstoffset+1]); | ||
1402 | + } else { | ||
1403 | + number_of_tags = GETJOCTET(data[firstoffset+1]); | ||
1404 | + number_of_tags <<= 8; | ||
1405 | + number_of_tags += GETJOCTET(data[firstoffset]); | ||
1406 | } | ||
1407 | - MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); | ||
1408 | - if (MCU_rows > 0) /* can't trim to 0 pixels */ | ||
1409 | - dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); | ||
1410 | + if (number_of_tags == 0) return; | ||
1411 | + firstoffset += 2; | ||
1412 | + | ||
1413 | + /* Search for ExifSubIFD offset Tag in IFD0 */ | ||
1414 | + for (;;) { | ||
1415 | + if (firstoffset > length - 12) return; /* check end of data segment */ | ||
1416 | + /* Get Tag number */ | ||
1417 | + if (is_motorola) { | ||
1418 | + tagnum = GETJOCTET(data[firstoffset]); | ||
1419 | + tagnum <<= 8; | ||
1420 | + tagnum += GETJOCTET(data[firstoffset+1]); | ||
1421 | + } else { | ||
1422 | + tagnum = GETJOCTET(data[firstoffset+1]); | ||
1423 | + tagnum <<= 8; | ||
1424 | + tagnum += GETJOCTET(data[firstoffset]); | ||
1425 | + } | ||
1426 | + if (tagnum == 0x8769) break; /* found ExifSubIFD offset Tag */ | ||
1427 | + if (--number_of_tags == 0) return; | ||
1428 | + firstoffset += 12; | ||
1429 | + } | ||
1430 | + | ||
1431 | + /* Get the ExifSubIFD offset */ | ||
1432 | + if (is_motorola) { | ||
1433 | + if (GETJOCTET(data[firstoffset+8]) != 0) return; | ||
1434 | + if (GETJOCTET(data[firstoffset+9]) != 0) return; | ||
1435 | + offset = GETJOCTET(data[firstoffset+10]); | ||
1436 | + offset <<= 8; | ||
1437 | + offset += GETJOCTET(data[firstoffset+11]); | ||
1438 | + } else { | ||
1439 | + if (GETJOCTET(data[firstoffset+11]) != 0) return; | ||
1440 | + if (GETJOCTET(data[firstoffset+10]) != 0) return; | ||
1441 | + offset = GETJOCTET(data[firstoffset+9]); | ||
1442 | + offset <<= 8; | ||
1443 | + offset += GETJOCTET(data[firstoffset+8]); | ||
1444 | + } | ||
1445 | + if (offset > length - 2) return; /* check end of data segment */ | ||
1446 | + | ||
1447 | + /* Get the number of directory entries contained in this SubIFD */ | ||
1448 | + if (is_motorola) { | ||
1449 | + number_of_tags = GETJOCTET(data[offset]); | ||
1450 | + number_of_tags <<= 8; | ||
1451 | + number_of_tags += GETJOCTET(data[offset+1]); | ||
1452 | + } else { | ||
1453 | + number_of_tags = GETJOCTET(data[offset+1]); | ||
1454 | + number_of_tags <<= 8; | ||
1455 | + number_of_tags += GETJOCTET(data[offset]); | ||
1456 | + } | ||
1457 | + if (number_of_tags < 2) return; | ||
1458 | + offset += 2; | ||
1459 | + | ||
1460 | + /* Search for ExifImageWidth and ExifImageHeight Tags in this SubIFD */ | ||
1461 | + do { | ||
1462 | + if (offset > length - 12) return; /* check end of data segment */ | ||
1463 | + /* Get Tag number */ | ||
1464 | + if (is_motorola) { | ||
1465 | + tagnum = GETJOCTET(data[offset]); | ||
1466 | + tagnum <<= 8; | ||
1467 | + tagnum += GETJOCTET(data[offset+1]); | ||
1468 | + } else { | ||
1469 | + tagnum = GETJOCTET(data[offset+1]); | ||
1470 | + tagnum <<= 8; | ||
1471 | + tagnum += GETJOCTET(data[offset]); | ||
1472 | + } | ||
1473 | + if (tagnum == 0xA002 || tagnum == 0xA003) { | ||
1474 | + if (tagnum == 0xA002) | ||
1475 | + new_value = new_width; /* ExifImageWidth Tag */ | ||
1476 | + else | ||
1477 | + new_value = new_height; /* ExifImageHeight Tag */ | ||
1478 | + if (is_motorola) { | ||
1479 | + data[offset+2] = 0; /* Format = unsigned long (4 octets) */ | ||
1480 | + data[offset+3] = 4; | ||
1481 | + data[offset+4] = 0; /* Number Of Components = 1 */ | ||
1482 | + data[offset+5] = 0; | ||
1483 | + data[offset+6] = 0; | ||
1484 | + data[offset+7] = 1; | ||
1485 | + data[offset+8] = 0; | ||
1486 | + data[offset+9] = 0; | ||
1487 | + data[offset+10] = (JOCTET)((new_value >> 8) & 0xFF); | ||
1488 | + data[offset+11] = (JOCTET)(new_value & 0xFF); | ||
1489 | + } else { | ||
1490 | + data[offset+2] = 4; /* Format = unsigned long (4 octets) */ | ||
1491 | + data[offset+3] = 0; | ||
1492 | + data[offset+4] = 1; /* Number Of Components = 1 */ | ||
1493 | + data[offset+5] = 0; | ||
1494 | + data[offset+6] = 0; | ||
1495 | + data[offset+7] = 0; | ||
1496 | + data[offset+8] = (JOCTET)(new_value & 0xFF); | ||
1497 | + data[offset+9] = (JOCTET)((new_value >> 8) & 0xFF); | ||
1498 | + data[offset+10] = 0; | ||
1499 | + data[offset+11] = 0; | ||
1500 | + } | ||
1501 | + } | ||
1502 | + offset += 12; | ||
1503 | + } while (--number_of_tags); | ||
1504 | } | ||
1505 | |||
1506 | |||
1507 | @@ -736,18 +1263,22 @@ | ||
1508 | { | ||
1509 | /* If force-to-grayscale is requested, adjust destination parameters */ | ||
1510 | if (info->force_grayscale) { | ||
1511 | - /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed | ||
1512 | - * properly. Among other things, the target h_samp_factor & v_samp_factor | ||
1513 | - * will get set to 1, which typically won't match the source. | ||
1514 | - * In fact we do this even if the source is already grayscale; that | ||
1515 | - * provides an easy way of coercing a grayscale JPEG with funny sampling | ||
1516 | - * factors to the customary 1,1. (Some decoders fail on other factors.) | ||
1517 | + /* First, ensure we have YCbCr or grayscale data, and that the source's | ||
1518 | + * Y channel is full resolution. (No reasonable person would make Y | ||
1519 | + * be less than full resolution, so actually coping with that case | ||
1520 | + * isn't worth extra code space. But we check it to avoid crashing.) | ||
1521 | */ | ||
1522 | - if ((dstinfo->jpeg_color_space == JCS_YCbCr && | ||
1523 | - dstinfo->num_components == 3) || | ||
1524 | - (dstinfo->jpeg_color_space == JCS_GRAYSCALE && | ||
1525 | - dstinfo->num_components == 1)) { | ||
1526 | - /* We have to preserve the source's quantization table number. */ | ||
1527 | + if (((dstinfo->jpeg_color_space == JCS_YCbCr && | ||
1528 | + dstinfo->num_components == 3) || | ||
1529 | + (dstinfo->jpeg_color_space == JCS_GRAYSCALE && | ||
1530 | + dstinfo->num_components == 1)) && | ||
1531 | + srcinfo->comp_info[0].h_samp_factor == srcinfo->max_h_samp_factor && | ||
1532 | + srcinfo->comp_info[0].v_samp_factor == srcinfo->max_v_samp_factor) { | ||
1533 | + /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed | ||
1534 | + * properly. Among other things, it sets the target h_samp_factor & | ||
1535 | + * v_samp_factor to 1, which typically won't match the source. | ||
1536 | + * We have to preserve the source's quantization table number, however. | ||
1537 | + */ | ||
1538 | int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; | ||
1539 | jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); | ||
1540 | dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; | ||
1541 | @@ -755,50 +1286,52 @@ | ||
1542 | /* Sorry, can't do it */ | ||
1543 | ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); | ||
1544 | } | ||
1545 | + } else if (info->num_components == 1) { | ||
1546 | + /* For a single-component source, we force the destination sampling factors | ||
1547 | + * to 1x1, with or without force_grayscale. This is useful because some | ||
1548 | + * decoders choke on grayscale images with other sampling factors. | ||
1549 | + */ | ||
1550 | + dstinfo->comp_info[0].h_samp_factor = 1; | ||
1551 | + dstinfo->comp_info[0].v_samp_factor = 1; | ||
1552 | } | ||
1553 | |||
1554 | - /* Correct the destination's image dimensions etc if necessary */ | ||
1555 | + /* Correct the destination's image dimensions as necessary | ||
1556 | + * for crop and rotate/flip operations. | ||
1557 | + */ | ||
1558 | + dstinfo->image_width = info->output_width; | ||
1559 | + dstinfo->image_height = info->output_height; | ||
1560 | + | ||
1561 | + /* Transpose destination image parameters */ | ||
1562 | switch (info->transform) { | ||
1563 | - case JXFORM_NONE: | ||
1564 | - /* Nothing to do */ | ||
1565 | - break; | ||
1566 | - case JXFORM_FLIP_H: | ||
1567 | - if (info->trim) | ||
1568 | - trim_right_edge(dstinfo); | ||
1569 | - break; | ||
1570 | - case JXFORM_FLIP_V: | ||
1571 | - if (info->trim) | ||
1572 | - trim_bottom_edge(dstinfo); | ||
1573 | - break; | ||
1574 | case JXFORM_TRANSPOSE: | ||
1575 | - transpose_critical_parameters(dstinfo); | ||
1576 | - /* transpose does NOT have to trim anything */ | ||
1577 | - break; | ||
1578 | case JXFORM_TRANSVERSE: | ||
1579 | - transpose_critical_parameters(dstinfo); | ||
1580 | - if (info->trim) { | ||
1581 | - trim_right_edge(dstinfo); | ||
1582 | - trim_bottom_edge(dstinfo); | ||
1583 | - } | ||
1584 | - break; | ||
1585 | case JXFORM_ROT_90: | ||
1586 | - transpose_critical_parameters(dstinfo); | ||
1587 | - if (info->trim) | ||
1588 | - trim_right_edge(dstinfo); | ||
1589 | - break; | ||
1590 | - case JXFORM_ROT_180: | ||
1591 | - if (info->trim) { | ||
1592 | - trim_right_edge(dstinfo); | ||
1593 | - trim_bottom_edge(dstinfo); | ||
1594 | - } | ||
1595 | - break; | ||
1596 | case JXFORM_ROT_270: | ||
1597 | transpose_critical_parameters(dstinfo); | ||
1598 | - if (info->trim) | ||
1599 | - trim_bottom_edge(dstinfo); | ||
1600 | break; | ||
1601 | } | ||
1602 | |||
1603 | + /* Adjust Exif properties */ | ||
1604 | + if (srcinfo->marker_list != NULL && | ||
1605 | + srcinfo->marker_list->marker == JPEG_APP0+1 && | ||
1606 | + srcinfo->marker_list->data_length >= 6 && | ||
1607 | + GETJOCTET(srcinfo->marker_list->data[0]) == 0x45 && | ||
1608 | + GETJOCTET(srcinfo->marker_list->data[1]) == 0x78 && | ||
1609 | + GETJOCTET(srcinfo->marker_list->data[2]) == 0x69 && | ||
1610 | + GETJOCTET(srcinfo->marker_list->data[3]) == 0x66 && | ||
1611 | + GETJOCTET(srcinfo->marker_list->data[4]) == 0 && | ||
1612 | + GETJOCTET(srcinfo->marker_list->data[5]) == 0) { | ||
1613 | + /* Suppress output of JFIF marker */ | ||
1614 | + dstinfo->write_JFIF_header = FALSE; | ||
1615 | + /* Adjust Exif image parameters */ | ||
1616 | + if (dstinfo->image_width != srcinfo->image_width || | ||
1617 | + dstinfo->image_height != srcinfo->image_height) | ||
1618 | + /* Align data segment to start of TIFF structure for parsing */ | ||
1619 | + adjust_exif_parameters(srcinfo->marker_list->data + 6, | ||
1620 | + srcinfo->marker_list->data_length - 6, | ||
1621 | + dstinfo->image_width, dstinfo->image_height); | ||
1622 | + } | ||
1623 | + | ||
1624 | /* Return the appropriate output data set */ | ||
1625 | if (info->workspace_coef_arrays != NULL) | ||
1626 | return info->workspace_coef_arrays; | ||
1627 | @@ -816,36 +1349,53 @@ | ||
1628 | */ | ||
1629 | |||
1630 | GLOBAL(void) | ||
1631 | -jtransform_execute_transformation (j_decompress_ptr srcinfo, | ||
1632 | - j_compress_ptr dstinfo, | ||
1633 | - jvirt_barray_ptr *src_coef_arrays, | ||
1634 | - jpeg_transform_info *info) | ||
1635 | +jtransform_execute_transform (j_decompress_ptr srcinfo, | ||
1636 | + j_compress_ptr dstinfo, | ||
1637 | + jvirt_barray_ptr *src_coef_arrays, | ||
1638 | + jpeg_transform_info *info) | ||
1639 | { | ||
1640 | jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; | ||
1641 | |||
1642 | + /* Note: conditions tested here should match those in switch statement | ||
1643 | + * in jtransform_request_workspace() | ||
1644 | + */ | ||
1645 | switch (info->transform) { | ||
1646 | case JXFORM_NONE: | ||
1647 | + if (info->x_crop_offset != 0 || info->y_crop_offset != 0) | ||
1648 | + do_crop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1649 | + src_coef_arrays, dst_coef_arrays); | ||
1650 | break; | ||
1651 | case JXFORM_FLIP_H: | ||
1652 | - do_flip_h(srcinfo, dstinfo, src_coef_arrays); | ||
1653 | + if (info->y_crop_offset != 0) | ||
1654 | + do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1655 | + src_coef_arrays, dst_coef_arrays); | ||
1656 | + else | ||
1657 | + do_flip_h_no_crop(srcinfo, dstinfo, info->x_crop_offset, | ||
1658 | + src_coef_arrays); | ||
1659 | break; | ||
1660 | case JXFORM_FLIP_V: | ||
1661 | - do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); | ||
1662 | + do_flip_v(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1663 | + src_coef_arrays, dst_coef_arrays); | ||
1664 | break; | ||
1665 | case JXFORM_TRANSPOSE: | ||
1666 | - do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); | ||
1667 | + do_transpose(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1668 | + src_coef_arrays, dst_coef_arrays); | ||
1669 | break; | ||
1670 | case JXFORM_TRANSVERSE: | ||
1671 | - do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); | ||
1672 | + do_transverse(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1673 | + src_coef_arrays, dst_coef_arrays); | ||
1674 | break; | ||
1675 | case JXFORM_ROT_90: | ||
1676 | - do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); | ||
1677 | + do_rot_90(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1678 | + src_coef_arrays, dst_coef_arrays); | ||
1679 | break; | ||
1680 | case JXFORM_ROT_180: | ||
1681 | - do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); | ||
1682 | + do_rot_180(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1683 | + src_coef_arrays, dst_coef_arrays); | ||
1684 | break; | ||
1685 | case JXFORM_ROT_270: | ||
1686 | - do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays); | ||
1687 | + do_rot_270(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, | ||
1688 | + src_coef_arrays, dst_coef_arrays); | ||
1689 | break; | ||
1690 | } | ||
1691 | } | ||
1692 | --- jpeg-6b/jerror.h~libjpeg6bb-5 | ||
1693 | +++ jpeg-6b/jerror.h | ||
1694 | @@ -45,6 +45,7 @@ | ||
1695 | JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") | ||
1696 | JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") | ||
1697 | JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") | ||
1698 | +JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") | ||
1699 | JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") | ||
1700 | JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") | ||
1701 | JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") | ||
1702 | --- jpeg-6b/transupp.h~libjpeg6bb-5 | ||
1703 | +++ jpeg-6b/transupp.h | ||
1704 | @@ -1,7 +1,7 @@ | ||
1705 | /* | ||
1706 | * transupp.h | ||
1707 | * | ||
1708 | - * Copyright (C) 1997, Thomas G. Lane. | ||
1709 | + * Copyright (C) 1997-2001, Thomas G. Lane. | ||
1710 | * This file is part of the Independent JPEG Group's software. | ||
1711 | * For conditions of distribution and use, see the accompanying README file. | ||
1712 | * | ||
1713 | @@ -22,32 +22,6 @@ | ||
1714 | #define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */ | ||
1715 | #endif | ||
1716 | |||
1717 | -/* Short forms of external names for systems with brain-damaged linkers. */ | ||
1718 | - | ||
1719 | -#ifdef NEED_SHORT_EXTERNAL_NAMES | ||
1720 | -#define jtransform_request_workspace jTrRequest | ||
1721 | -#define jtransform_adjust_parameters jTrAdjust | ||
1722 | -#define jtransform_execute_transformation jTrExec | ||
1723 | -#define jcopy_markers_setup jCMrkSetup | ||
1724 | -#define jcopy_markers_execute jCMrkExec | ||
1725 | -#endif /* NEED_SHORT_EXTERNAL_NAMES */ | ||
1726 | - | ||
1727 | - | ||
1728 | -/* | ||
1729 | - * Codes for supported types of image transformations. | ||
1730 | - */ | ||
1731 | - | ||
1732 | -typedef enum { | ||
1733 | - JXFORM_NONE, /* no transformation */ | ||
1734 | - JXFORM_FLIP_H, /* horizontal flip */ | ||
1735 | - JXFORM_FLIP_V, /* vertical flip */ | ||
1736 | - JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ | ||
1737 | - JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ | ||
1738 | - JXFORM_ROT_90, /* 90-degree clockwise rotation */ | ||
1739 | - JXFORM_ROT_180, /* 180-degree rotation */ | ||
1740 | - JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ | ||
1741 | -} JXFORM_CODE; | ||
1742 | - | ||
1743 | /* | ||
1744 | * Although rotating and flipping data expressed as DCT coefficients is not | ||
1745 | * hard, there is an asymmetry in the JPEG format specification for images | ||
1746 | @@ -75,6 +49,19 @@ | ||
1747 | * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim | ||
1748 | * followed by -rot 180 -trim trims both edges.) | ||
1749 | * | ||
1750 | + * We also offer a lossless-crop option, which discards data outside a given | ||
1751 | + * image region but losslessly preserves what is inside. Like the rotate and | ||
1752 | + * flip transforms, lossless crop is restricted by the JPEG format: the upper | ||
1753 | + * left corner of the selected region must fall on an iMCU boundary. If this | ||
1754 | + * does not hold for the given crop parameters, we silently move the upper left | ||
1755 | + * corner up and/or left to make it so, simultaneously increasing the region | ||
1756 | + * dimensions to keep the lower right crop corner unchanged. (Thus, the | ||
1757 | + * output image covers at least the requested region, but may cover more.) | ||
1758 | + * | ||
1759 | + * If both crop and a rotate/flip transform are requested, the crop is applied | ||
1760 | + * last --- that is, the crop region is specified in terms of the destination | ||
1761 | + * image. | ||
1762 | + * | ||
1763 | * We also offer a "force to grayscale" option, which simply discards the | ||
1764 | * chrominance channels of a YCbCr image. This is lossless in the sense that | ||
1765 | * the luminance channel is preserved exactly. It's not the same kind of | ||
1766 | @@ -83,20 +70,87 @@ | ||
1767 | * be aware of the option to know how many components to work on. | ||
1768 | */ | ||
1769 | |||
1770 | + | ||
1771 | +/* Short forms of external names for systems with brain-damaged linkers. */ | ||
1772 | + | ||
1773 | +#ifdef NEED_SHORT_EXTERNAL_NAMES | ||
1774 | +#define jtransform_parse_crop_spec jTrParCrop | ||
1775 | +#define jtransform_request_workspace jTrRequest | ||
1776 | +#define jtransform_adjust_parameters jTrAdjust | ||
1777 | +#define jtransform_execute_transform jTrExec | ||
1778 | +#define jcopy_markers_setup jCMrkSetup | ||
1779 | +#define jcopy_markers_execute jCMrkExec | ||
1780 | +#endif /* NEED_SHORT_EXTERNAL_NAMES */ | ||
1781 | + | ||
1782 | + | ||
1783 | +/* | ||
1784 | + * Codes for supported types of image transformations. | ||
1785 | + */ | ||
1786 | + | ||
1787 | +typedef enum { | ||
1788 | + JXFORM_NONE, /* no transformation */ | ||
1789 | + JXFORM_FLIP_H, /* horizontal flip */ | ||
1790 | + JXFORM_FLIP_V, /* vertical flip */ | ||
1791 | + JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */ | ||
1792 | + JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */ | ||
1793 | + JXFORM_ROT_90, /* 90-degree clockwise rotation */ | ||
1794 | + JXFORM_ROT_180, /* 180-degree rotation */ | ||
1795 | + JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */ | ||
1796 | +} JXFORM_CODE; | ||
1797 | + | ||
1798 | +/* | ||
1799 | + * Codes for crop parameters, which can individually be unspecified, | ||
1800 | + * positive, or negative. (Negative width or height makes no sense, though.) | ||
1801 | + */ | ||
1802 | + | ||
1803 | +typedef enum { | ||
1804 | + JCROP_UNSET, | ||
1805 | + JCROP_POS, | ||
1806 | + JCROP_NEG | ||
1807 | +} JCROP_CODE; | ||
1808 | + | ||
1809 | +/* | ||
1810 | + * Transform parameters struct. | ||
1811 | + * NB: application must not change any elements of this struct after | ||
1812 | + * calling jtransform_request_workspace. | ||
1813 | + */ | ||
1814 | + | ||
1815 | typedef struct { | ||
1816 | /* Options: set by caller */ | ||
1817 | JXFORM_CODE transform; /* image transform operator */ | ||
1818 | boolean trim; /* if TRUE, trim partial MCUs as needed */ | ||
1819 | boolean force_grayscale; /* if TRUE, convert color image to grayscale */ | ||
1820 | + boolean crop; /* if TRUE, crop source image */ | ||
1821 | + | ||
1822 | + /* Crop parameters: application need not set these unless crop is TRUE. | ||
1823 | + * These can be filled in by jtransform_parse_crop_spec(). | ||
1824 | + */ | ||
1825 | + JDIMENSION crop_width; /* Width of selected region */ | ||
1826 | + JCROP_CODE crop_width_set; | ||
1827 | + JDIMENSION crop_height; /* Height of selected region */ | ||
1828 | + JCROP_CODE crop_height_set; | ||
1829 | + JDIMENSION crop_xoffset; /* X offset of selected region */ | ||
1830 | + JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */ | ||
1831 | + JDIMENSION crop_yoffset; /* Y offset of selected region */ | ||
1832 | + JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */ | ||
1833 | |||
1834 | /* Internal workspace: caller should not touch these */ | ||
1835 | int num_components; /* # of components in workspace */ | ||
1836 | jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */ | ||
1837 | + JDIMENSION output_width; /* cropped destination dimensions */ | ||
1838 | + JDIMENSION output_height; | ||
1839 | + JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */ | ||
1840 | + JDIMENSION y_crop_offset; | ||
1841 | + int max_h_samp_factor; /* destination iMCU size */ | ||
1842 | + int max_v_samp_factor; | ||
1843 | } jpeg_transform_info; | ||
1844 | |||
1845 | |||
1846 | #if TRANSFORMS_SUPPORTED | ||
1847 | |||
1848 | +/* Parse a crop specification (written in X11 geometry style) */ | ||
1849 | +EXTERN(boolean) jtransform_parse_crop_spec | ||
1850 | + JPP((jpeg_transform_info *info, const char *spec)); | ||
1851 | /* Request any required workspace */ | ||
1852 | EXTERN(void) jtransform_request_workspace | ||
1853 | JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info)); | ||
1854 | @@ -106,11 +160,18 @@ | ||
1855 | jvirt_barray_ptr *src_coef_arrays, | ||
1856 | jpeg_transform_info *info)); | ||
1857 | /* Execute the actual transformation, if any */ | ||
1858 | -EXTERN(void) jtransform_execute_transformation | ||
1859 | +EXTERN(void) jtransform_execute_transform | ||
1860 | JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo, | ||
1861 | jvirt_barray_ptr *src_coef_arrays, | ||
1862 | jpeg_transform_info *info)); | ||
1863 | |||
1864 | +/* jtransform_execute_transform used to be called | ||
1865 | + * jtransform_execute_transformation, but some compilers complain about | ||
1866 | + * routine names that long. This macro is here to avoid breaking any | ||
1867 | + * old source code that uses the original name... | ||
1868 | + */ | ||
1869 | +#define jtransform_execute_transformation jtransform_execute_transform | ||
1870 | + | ||
1871 | #endif /* TRANSFORMS_SUPPORTED */ | ||
1872 | |||
1873 | |||
1874 | |||
diff --git a/meta/packages/jpeg/jpeg-6b/ldflags.patch b/meta/packages/jpeg/jpeg-6b/ldflags.patch deleted file mode 100644 index 727327bc6e..0000000000 --- a/meta/packages/jpeg/jpeg-6b/ldflags.patch +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | |||
2 | # | ||
3 | # Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher | ||
4 | # | ||
5 | |||
6 | --- jpeg-6b/makefile.cfg~ldflags | ||
7 | +++ jpeg-6b/makefile.cfg | ||
8 | @@ -169,7 +169,7 @@ | ||
9 | # with libtool: | ||
10 | libjpeg.la: @A2K_DEPS@ $(LIBOBJECTS) | ||
11 | $(LIBTOOL) --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ | ||
12 | - -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) | ||
13 | + -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) $(LDFLAGS) | ||
14 | |||
15 | # sample programs: | ||
16 | |||
diff --git a/meta/packages/jpeg/jpeg-6b/libtool_tweak.patch b/meta/packages/jpeg/jpeg-6b/libtool_tweak.patch deleted file mode 100644 index d61476adc0..0000000000 --- a/meta/packages/jpeg/jpeg-6b/libtool_tweak.patch +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | Index: jpeg-6b/configure | ||
2 | =================================================================== | ||
3 | --- jpeg-6b.orig/configure 2008-05-07 15:53:15.000000000 +0100 | ||
4 | +++ jpeg-6b/configure 2008-05-07 15:54:40.000000000 +0100 | ||
5 | @@ -1532,7 +1532,7 @@ | ||
6 | LIBTOOL="./libtool" | ||
7 | O="lo" | ||
8 | A="la" | ||
9 | - LN='$(LIBTOOL) --mode=link $(CC)' | ||
10 | + LN='$(LIBTOOL) --tag=CC --mode=link $(CC)' | ||
11 | INSTALL_LIB='$(LIBTOOL) --mode=install ${INSTALL}' | ||
12 | INSTALL_PROGRAM="\$(LIBTOOL) --mode=install $INSTALL_PROGRAM" | ||
13 | else | ||
14 | @@ -1559,7 +1559,6 @@ | ||
15 | if test "x$LTSTATIC" = xno; then | ||
16 | disable_static="--disable-static" | ||
17 | fi | ||
18 | - $srcdir/ltconfig $disable_shared $disable_static $srcdir/ltmain.sh | ||
19 | fi | ||
20 | |||
21 | # Select memory manager depending on user input. | ||
22 | Index: jpeg-6b/makefile.cfg | ||
23 | =================================================================== | ||
24 | --- jpeg-6b.orig/makefile.cfg 2008-05-07 15:53:24.000000000 +0100 | ||
25 | +++ jpeg-6b/makefile.cfg 2008-05-07 15:56:22.000000000 +0100 | ||
26 | @@ -141,7 +141,7 @@ | ||
27 | |||
28 | # How to compile with libtool. | ||
29 | @COM_LT@.c.lo: | ||
30 | -@COM_LT@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c | ||
31 | +@COM_LT@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c | ||
32 | |||
33 | # How to use ansi2knr, when not using libtool. | ||
34 | @COM_A2K@.c.o: | ||
35 | @@ -152,7 +152,7 @@ | ||
36 | # How to use ansi2knr AND libtool. | ||
37 | @COM_A2K@.c.lo: | ||
38 | @COM_A2K@ ./ansi2knr $(srcdir)/$*.c knr/$*.c | ||
39 | -@COM_A2K@ $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c knr/$*.c | ||
40 | +@COM_A2K@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(CFLAGS) -c knr/$*.c | ||
41 | @COM_A2K@ $(RM) knr/$*.c | ||
42 | |||
43 | ansi2knr: ansi2knr.c | ||
44 | @@ -169,7 +169,7 @@ | ||
45 | |||
46 | # with libtool: | ||
47 | libjpeg.la: @A2K_DEPS@ $(LIBOBJECTS) | ||
48 | - $(LIBTOOL) --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ | ||
49 | + $(LIBTOOL) --tag=CC --mode=link $(CC) -o libjpeg.la $(LIBOBJECTS) \ | ||
50 | -rpath $(libdir) -version-info $(JPEG_LIB_VERSION) $(LDFLAGS) | ||
51 | |||
52 | # sample programs: | ||
diff --git a/meta/packages/jpeg/jpeg-6b/paths.patch b/meta/packages/jpeg/jpeg-6b/paths.patch deleted file mode 100644 index 014bf4ec0f..0000000000 --- a/meta/packages/jpeg/jpeg-6b/paths.patch +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | |||
2 | # | ||
3 | # Patch managed by http://www.holgerschurig.de/patcher.html | ||
4 | # | ||
5 | |||
6 | --- jpeg-6b/makefile.cfg~paths.patch | ||
7 | +++ jpeg-6b/makefile.cfg | ||
8 | @@ -7,17 +7,18 @@ | ||
9 | # For compiling with source and object files in different directories. | ||
10 | srcdir = @srcdir@ | ||
11 | VPATH = @srcdir@ | ||
12 | +DESTDIR = @DESTDIR@ | ||
13 | |||
14 | # Where to install the programs and man pages. | ||
15 | prefix = @prefix@ | ||
16 | exec_prefix = @exec_prefix@ | ||
17 | -bindir = $(exec_prefix)/bin | ||
18 | -libdir = $(exec_prefix)/lib | ||
19 | -includedir = $(prefix)/include | ||
20 | +bindir = @bindir@ | ||
21 | +libdir = @libdir@ | ||
22 | +includedir = @includedir@ | ||
23 | binprefix = | ||
24 | manprefix = | ||
25 | manext = 1 | ||
26 | -mandir = $(prefix)/share/man/man$(manext) | ||
27 | +mandir = @mandir@/man$(manext) | ||
28 | |||
29 | # The name of your C compiler: | ||
30 | CC= @CC@ | ||
31 | @@ -191,30 +192,30 @@ | ||
32 | # Installation rules: | ||
33 | |||
34 | install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom @FORCE_INSTALL_LIB@ | ||
35 | - $(INSTALL_PROGRAM) cjpeg $(bindir)/$(binprefix)cjpeg | ||
36 | - $(INSTALL_PROGRAM) djpeg $(bindir)/$(binprefix)djpeg | ||
37 | - $(INSTALL_PROGRAM) jpegtran $(bindir)/$(binprefix)jpegtran | ||
38 | - $(INSTALL_PROGRAM) rdjpgcom $(bindir)/$(binprefix)rdjpgcom | ||
39 | - $(INSTALL_PROGRAM) wrjpgcom $(bindir)/$(binprefix)wrjpgcom | ||
40 | - $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(mandir)/$(manprefix)cjpeg.$(manext) | ||
41 | - $(INSTALL_DATA) $(srcdir)/djpeg.1 $(mandir)/$(manprefix)djpeg.$(manext) | ||
42 | - $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(mandir)/$(manprefix)jpegtran.$(manext) | ||
43 | - $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(mandir)/$(manprefix)rdjpgcom.$(manext) | ||
44 | - $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(mandir)/$(manprefix)wrjpgcom.$(manext) | ||
45 | + $(INSTALL_PROGRAM) cjpeg $(DESTDIR)$(bindir)/$(binprefix)cjpeg | ||
46 | + $(INSTALL_PROGRAM) djpeg $(DESTDIR)$(bindir)/$(binprefix)djpeg | ||
47 | + $(INSTALL_PROGRAM) jpegtran $(DESTDIR)$(bindir)/$(binprefix)jpegtran | ||
48 | + $(INSTALL_PROGRAM) rdjpgcom $(DESTDIR)$(bindir)/$(binprefix)rdjpgcom | ||
49 | + $(INSTALL_PROGRAM) wrjpgcom $(DESTDIR)$(bindir)/$(binprefix)wrjpgcom | ||
50 | + $(INSTALL_DATA) $(srcdir)/cjpeg.1 $(DESTDIR)$(mandir)/$(manprefix)cjpeg.$(manext) | ||
51 | + $(INSTALL_DATA) $(srcdir)/djpeg.1 $(DESTDIR)$(mandir)/$(manprefix)djpeg.$(manext) | ||
52 | + $(INSTALL_DATA) $(srcdir)/jpegtran.1 $(DESTDIR)$(mandir)/$(manprefix)jpegtran.$(manext) | ||
53 | + $(INSTALL_DATA) $(srcdir)/rdjpgcom.1 $(DESTDIR)$(mandir)/$(manprefix)rdjpgcom.$(manext) | ||
54 | + $(INSTALL_DATA) $(srcdir)/wrjpgcom.1 $(DESTDIR)$(mandir)/$(manprefix)wrjpgcom.$(manext) | ||
55 | |||
56 | install-lib: libjpeg.$(A) install-headers | ||
57 | - $(INSTALL_LIB) libjpeg.$(A) $(libdir)/$(binprefix)libjpeg.$(A) | ||
58 | + $(INSTALL_LIB) libjpeg.$(A) $(DESTDIR)$(libdir)/$(binprefix)libjpeg.$(A) | ||
59 | |||
60 | install-headers: jconfig.h | ||
61 | - $(INSTALL_DATA) jconfig.h $(includedir)/jconfig.h | ||
62 | - $(INSTALL_DATA) $(srcdir)/jpeglib.h $(includedir)/jpeglib.h | ||
63 | - $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(includedir)/jmorecfg.h | ||
64 | - $(INSTALL_DATA) $(srcdir)/jerror.h $(includedir)/jerror.h | ||
65 | + $(INSTALL_DATA) jconfig.h $(DESTDIR)$(includedir)/jconfig.h | ||
66 | + $(INSTALL_DATA) $(srcdir)/jpeglib.h $(DESTDIR)$(includedir)/jpeglib.h | ||
67 | + $(INSTALL_DATA) $(srcdir)/jmorecfg.h $(DESTDIR)$(includedir)/jmorecfg.h | ||
68 | + $(INSTALL_DATA) $(srcdir)/jerror.h $(DESTDIR)$(includedir)/jerror.h | ||
69 | #<ballombe@debian.org>:mjpegtools require this file to build and header say: | ||
70 | # * These declarations are considered internal to the JPEG library; most | ||
71 | # * applications using the library shouldn't need to include this file. | ||
72 | # So it is not forbidden to use it, therefore it must be installed. | ||
73 | - $(INSTALL_DATA) $(srcdir)/jpegint.h $(includedir)/jpegint.h | ||
74 | + $(INSTALL_DATA) $(srcdir)/jpegint.h $(DESTDIR)$(includedir)/jpegint.h | ||
75 | |||
76 | clean: | ||
77 | $(RM) *.o *.lo libjpeg.a libjpeg.la | ||