Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 479476 | Differences between
and this patch

Collapse All | Expand All

(-) (+26 lines)
Added Link Here
1
/*
2
 * jpegcomp.h
3
 *
4
 * Copyright (C) 2010, D. R. Commander
5
 * For conditions of distribution and use, see the accompanying README file.
6
 *
7
 * JPEG compatibility macros
8
 * These declarations are considered internal to the JPEG library; most
9
 * applications using the library shouldn't need to include this file.
10
 */
11
12
#if JPEG_LIB_VERSION >= 70
13
#define _DCT_scaled_size DCT_h_scaled_size
14
#define _min_DCT_scaled_size min_DCT_h_scaled_size
15
#define _min_DCT_h_scaled_size min_DCT_h_scaled_size
16
#define _min_DCT_v_scaled_size min_DCT_v_scaled_size
17
#define _jpeg_width jpeg_width
18
#define _jpeg_height jpeg_height
19
#else
20
#define _DCT_scaled_size DCT_scaled_size
21
#define _min_DCT_scaled_size min_DCT_scaled_size
22
#define _min_DCT_h_scaled_size min_DCT_scaled_size
23
#define _min_DCT_v_scaled_size min_DCT_scaled_size
24
#define _jpeg_width image_width
25
#define _jpeg_height image_height
26
#endif
(-)Source-orig/LibJPEG/jpegint.h (-42 / +17 lines)
Lines 2-8 Link Here
2
 * jpegint.h
2
 * jpegint.h
3
 *
3
 *
4
 * Copyright (C) 1991-1997, Thomas G. Lane.
4
 * Copyright (C) 1991-1997, Thomas G. Lane.
5
 * Modified 1997-2011 by Guido Vollbeding.
5
 * Modified 1997-2009 by Guido Vollbeding.
6
 * This file is part of the Independent JPEG Group's software.
6
 * This file is part of the Independent JPEG Group's software.
7
 * For conditions of distribution and use, see the accompanying README file.
7
 * For conditions of distribution and use, see the accompanying README file.
8
 *
8
 *
Lines 100-115 Link Here
100
};
100
};
101
101
102
/* Forward DCT (also controls coefficient quantization) */
102
/* Forward DCT (also controls coefficient quantization) */
103
typedef JMETHOD(void, forward_DCT_ptr,
104
		(j_compress_ptr cinfo, jpeg_component_info * compptr,
105
		 JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
106
		 JDIMENSION start_row, JDIMENSION start_col,
107
		 JDIMENSION num_blocks));
108
109
struct jpeg_forward_dct {
103
struct jpeg_forward_dct {
110
  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
104
  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
111
  /* It is useful to allow each component to have a separate FDCT method. */
105
  /* perhaps this should be an array??? */
112
  forward_DCT_ptr forward_DCT[MAX_COMPONENTS];
106
  JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
107
			      jpeg_component_info * compptr,
108
			      JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
109
			      JDIMENSION start_row, JDIMENSION start_col,
110
			      JDIMENSION num_blocks));
113
};
111
};
114
112
115
/* Entropy encoding */
113
/* Entropy encoding */
Lines 213-218 Link Here
213
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
211
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
214
  JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
212
  JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
215
				JBLOCKROW *MCU_data));
213
				JBLOCKROW *MCU_data));
214
215
  /* This is here to share code between baseline and progressive decoders; */
216
  /* other modules probably should not use it */
217
  boolean insufficient_data;	/* set TRUE after emitting warning */
216
};
218
};
217
219
218
/* Inverse DCT (also performs dequantization) */
220
/* Inverse DCT (also performs dequantization) */
Lines 302-307 Link Here
302
#define jinit_downsampler	jIDownsampler
304
#define jinit_downsampler	jIDownsampler
303
#define jinit_forward_dct	jIFDCT
305
#define jinit_forward_dct	jIFDCT
304
#define jinit_huff_encoder	jIHEncoder
306
#define jinit_huff_encoder	jIHEncoder
307
#define jinit_phuff_encoder	jIPHEncoder
305
#define jinit_arith_encoder	jIAEncoder
308
#define jinit_arith_encoder	jIAEncoder
306
#define jinit_marker_writer	jIMWriter
309
#define jinit_marker_writer	jIMWriter
307
#define jinit_master_decompress	jIDMaster
310
#define jinit_master_decompress	jIDMaster
Lines 311-316 Link Here
311
#define jinit_input_controller	jIInCtlr
314
#define jinit_input_controller	jIInCtlr
312
#define jinit_marker_reader	jIMReader
315
#define jinit_marker_reader	jIMReader
313
#define jinit_huff_decoder	jIHDecoder
316
#define jinit_huff_decoder	jIHDecoder
317
#define jinit_phuff_decoder	jIPHDecoder
314
#define jinit_arith_decoder	jIADecoder
318
#define jinit_arith_decoder	jIADecoder
315
#define jinit_inverse_dct	jIIDCT
319
#define jinit_inverse_dct	jIIDCT
316
#define jinit_upsampler		jIUpsampler
320
#define jinit_upsampler		jIUpsampler
Lines 321-361 Link Here
321
#define jinit_memory_mgr	jIMemMgr
325
#define jinit_memory_mgr	jIMemMgr
322
#define jdiv_round_up		jDivRound
326
#define jdiv_round_up		jDivRound
323
#define jround_up		jRound
327
#define jround_up		jRound
324
#define jzero_far		jZeroFar
325
#define jcopy_sample_rows	jCopySamples
328
#define jcopy_sample_rows	jCopySamples
326
#define jcopy_block_row		jCopyBlocks
329
#define jcopy_block_row		jCopyBlocks
330
#define jzero_far		jZeroFar
327
#define jpeg_zigzag_order	jZIGTable
331
#define jpeg_zigzag_order	jZIGTable
328
#define jpeg_natural_order	jZAGTable
332
#define jpeg_natural_order	jZAGTable
329
#define jpeg_natural_order7	jZAG7Table
330
#define jpeg_natural_order6	jZAG6Table
331
#define jpeg_natural_order5	jZAG5Table
332
#define jpeg_natural_order4	jZAG4Table
333
#define jpeg_natural_order3	jZAG3Table
334
#define jpeg_natural_order2	jZAG2Table
335
#define jpeg_aritab		jAriTab
333
#define jpeg_aritab		jAriTab
336
#endif /* NEED_SHORT_EXTERNAL_NAMES */
334
#endif /* NEED_SHORT_EXTERNAL_NAMES */
337
335
338
336
339
/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays
340
 * and coefficient-block arrays.  This won't work on 80x86 because the arrays
341
 * are FAR and we're assuming a small-pointer memory model.  However, some
342
 * DOS compilers provide far-pointer versions of memcpy() and memset() even
343
 * in the small-model libraries.  These will be used if USE_FMEM is defined.
344
 * Otherwise, the routines in jutils.c do it the hard way.
345
 */
346
347
#ifndef NEED_FAR_POINTERS	/* normal case, same as regular macro */
348
#define FMEMZERO(target,size)	MEMZERO(target,size)
349
#else				/* 80x86 case */
350
#ifdef USE_FMEM
351
#define FMEMZERO(target,size)	_fmemset((void FAR *)(target), 0, (size_t)(size))
352
#else
353
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
354
#define FMEMZERO(target,size)	jzero_far(target, size)
355
#endif
356
#endif
357
358
359
/* Compression module initialization routines */
337
/* Compression module initialization routines */
360
EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
338
EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
361
EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
339
EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
Lines 370-375 Link Here
370
EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
348
EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
371
EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
349
EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
372
EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
350
EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
351
EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
373
EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo));
352
EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo));
374
EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
353
EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
375
/* Decompression module initialization routines */
354
/* Decompression module initialization routines */
Lines 383-388 Link Here
383
EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
362
EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
384
EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
363
EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
385
EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
364
EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
365
EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
386
EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo));
366
EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo));
387
EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
367
EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
388
EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
368
EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
Lines 401-417 Link Here
401
				    int num_rows, JDIMENSION num_cols));
381
				    int num_rows, JDIMENSION num_cols));
402
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
382
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
403
				  JDIMENSION num_blocks));
383
				  JDIMENSION num_blocks));
384
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
404
/* Constant tables in jutils.c */
385
/* Constant tables in jutils.c */
405
#if 0				/* This table is not actually needed in v6a */
386
#if 0				/* This table is not actually needed in v6a */
406
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
387
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
407
#endif
388
#endif
408
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
389
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
409
extern const int jpeg_natural_order7[]; /* zz to natural order for 7x7 block */
410
extern const int jpeg_natural_order6[]; /* zz to natural order for 6x6 block */
411
extern const int jpeg_natural_order5[]; /* zz to natural order for 5x5 block */
412
extern const int jpeg_natural_order4[]; /* zz to natural order for 4x4 block */
413
extern const int jpeg_natural_order3[]; /* zz to natural order for 3x3 block */
414
extern const int jpeg_natural_order2[]; /* zz to natural order for 2x2 block */
415
390
416
/* Arithmetic coding probability estimation tables in jaricom.c */
391
/* Arithmetic coding probability estimation tables in jaricom.c */
417
extern const INT32 jpeg_aritab[];
392
extern const INT32 jpeg_aritab[];
(-)Source-orig/LibJPEG/transupp.h (-10 / +14 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * transupp.h
2
 * transupp.h
3
 *
3
 *
4
 * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
4
 * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding.
5
 * This file is part of the Independent JPEG Group's software.
5
 * This file is part of the Independent JPEG Group's software.
6
 * For conditions of distribution and use, see the accompanying README file.
6
 * For conditions of distribution and use, see the accompanying README file.
7
 *
7
 *
Lines 57-63 Link Here
57
 * corner up and/or left to make it so, simultaneously increasing the region
57
 * corner up and/or left to make it so, simultaneously increasing the region
58
 * dimensions to keep the lower right crop corner unchanged.  (Thus, the
58
 * dimensions to keep the lower right crop corner unchanged.  (Thus, the
59
 * output image covers at least the requested region, but may cover more.)
59
 * output image covers at least the requested region, but may cover more.)
60
 * The adjustment of the region dimensions may be optionally disabled.
61
 *
60
 *
62
 * We also provide a lossless-resize option, which is kind of a lossless-crop
61
 * We also provide a lossless-resize option, which is kind of a lossless-crop
63
 * operation in the DCT coefficient block domain - it discards higher-order
62
 * operation in the DCT coefficient block domain - it discards higher-order
Lines 107-121 Link Here
107
106
108
/*
107
/*
109
 * Codes for crop parameters, which can individually be unspecified,
108
 * Codes for crop parameters, which can individually be unspecified,
110
 * positive or negative for xoffset or yoffset,
109
 * positive, or negative.  (Negative width or height makes no sense, though.)
111
 * positive or forced for width or height.
112
 */
110
 */
113
111
114
typedef enum {
112
typedef enum {
115
        JCROP_UNSET,
113
	JCROP_UNSET,
116
        JCROP_POS,
114
	JCROP_POS,
117
        JCROP_NEG,
115
	JCROP_NEG
118
        JCROP_FORCE
119
} JCROP_CODE;
116
} JCROP_CODE;
120
117
121
/*
118
/*
Lines 131-144 Link Here
131
  boolean trim;			/* if TRUE, trim partial MCUs as needed */
128
  boolean trim;			/* if TRUE, trim partial MCUs as needed */
132
  boolean force_grayscale;	/* if TRUE, convert color image to grayscale */
129
  boolean force_grayscale;	/* if TRUE, convert color image to grayscale */
133
  boolean crop;			/* if TRUE, crop source image */
130
  boolean crop;			/* if TRUE, crop source image */
131
  boolean slow_hflip;  /* For best performance, the JXFORM_FLIP_H transform
132
                          normally modifies the source coefficients in place.
133
                          Setting this to TRUE will instead use a slower,
134
                          double-buffered algorithm, which leaves the source
135
                          coefficients in tact (necessary if other transformed
136
                          images must be generated from the same set of
137
                          coefficients. */
134
138
135
  /* Crop parameters: application need not set these unless crop is TRUE.
139
  /* Crop parameters: application need not set these unless crop is TRUE.
136
   * These can be filled in by jtransform_parse_crop_spec().
140
   * These can be filled in by jtransform_parse_crop_spec().
137
   */
141
   */
138
  JDIMENSION crop_width;	/* Width of selected region */
142
  JDIMENSION crop_width;	/* Width of selected region */
139
  JCROP_CODE crop_width_set;	/* (forced disables adjustment) */
143
  JCROP_CODE crop_width_set;
140
  JDIMENSION crop_height;	/* Height of selected region */
144
  JDIMENSION crop_height;	/* Height of selected region */
141
  JCROP_CODE crop_height_set;	/* (forced disables adjustment) */
145
  JCROP_CODE crop_height_set;
142
  JDIMENSION crop_xoffset;	/* X offset of selected region */
146
  JDIMENSION crop_xoffset;	/* X offset of selected region */
143
  JCROP_CODE crop_xoffset_set;	/* (negative measures from right edge) */
147
  JCROP_CODE crop_xoffset_set;	/* (negative measures from right edge) */
144
  JDIMENSION crop_yoffset;	/* Y offset of selected region */
148
  JDIMENSION crop_yoffset;	/* Y offset of selected region */
(-)Source-orig/LibJPEG/transupp.c (-46 / +62 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * transupp.c
2
 * transupp.c
3
 *
3
 *
4
 * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding.
4
 * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding.
5
 * Copyright (C) 2010, D. R. Commander.
5
 * This file is part of the Independent JPEG Group's software.
6
 * This file is part of the Independent JPEG Group's software.
6
 * For conditions of distribution and use, see the accompanying README file.
7
 * For conditions of distribution and use, see the accompanying README file.
7
 *
8
 *
Lines 20-28 Link Here
20
#include "jinclude.h"
21
#include "jinclude.h"
21
#include "jpeglib.h"
22
#include "jpeglib.h"
22
#include "transupp.h"		/* My own external interface */
23
#include "transupp.h"		/* My own external interface */
24
#include "jpegcomp.h"
23
#include <ctype.h>		/* to declare isdigit() */
25
#include <ctype.h>		/* to declare isdigit() */
24
26
25
27
28
#if JPEG_LIB_VERSION >= 70
29
#define dstinfo_min_DCT_h_scaled_size dstinfo->min_DCT_h_scaled_size
30
#define dstinfo_min_DCT_v_scaled_size dstinfo->min_DCT_v_scaled_size
31
#else
32
#define dstinfo_min_DCT_h_scaled_size DCTSIZE
33
#define dstinfo_min_DCT_v_scaled_size DCTSIZE
34
#endif
35
36
26
#if TRANSFORMS_SUPPORTED
37
#if TRANSFORMS_SUPPORTED
27
38
28
/*
39
/*
Lines 134-140 Link Here
134
   * Partial iMCUs at the right edge are left untouched.
145
   * Partial iMCUs at the right edge are left untouched.
135
   */
146
   */
136
  MCU_cols = srcinfo->output_width /
147
  MCU_cols = srcinfo->output_width /
137
    (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
148
    (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
138
149
139
  for (ci = 0; ci < dstinfo->num_components; ci++) {
150
  for (ci = 0; ci < dstinfo->num_components; ci++) {
140
    compptr = dstinfo->comp_info + ci;
151
    compptr = dstinfo->comp_info + ci;
Lines 200-206 Link Here
200
   * this is essentially the same as the routine above.
211
   * this is essentially the same as the routine above.
201
   */
212
   */
202
  MCU_cols = srcinfo->output_width /
213
  MCU_cols = srcinfo->output_width /
203
    (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
214
    (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
204
215
205
  for (ci = 0; ci < dstinfo->num_components; ci++) {
216
  for (ci = 0; ci < dstinfo->num_components; ci++) {
206
    compptr = dstinfo->comp_info + ci;
217
    compptr = dstinfo->comp_info + ci;
Lines 265-271 Link Here
265
   * Partial iMCUs at the bottom edge are copied verbatim.
276
   * Partial iMCUs at the bottom edge are copied verbatim.
266
   */
277
   */
267
  MCU_rows = srcinfo->output_height /
278
  MCU_rows = srcinfo->output_height /
268
    (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
279
    (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
269
280
270
  for (ci = 0; ci < dstinfo->num_components; ci++) {
281
  for (ci = 0; ci < dstinfo->num_components; ci++) {
271
    compptr = dstinfo->comp_info + ci;
282
    compptr = dstinfo->comp_info + ci;
Lines 393-399 Link Here
393
   * not mirrored.
404
   * not mirrored.
394
   */
405
   */
395
  MCU_cols = srcinfo->output_height /
406
  MCU_cols = srcinfo->output_height /
396
    (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
407
    (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
397
408
398
  for (ci = 0; ci < dstinfo->num_components; ci++) {
409
  for (ci = 0; ci < dstinfo->num_components; ci++) {
399
    compptr = dstinfo->comp_info + ci;
410
    compptr = dstinfo->comp_info + ci;
Lines 474-480 Link Here
474
   * not mirrored.
485
   * not mirrored.
475
   */
486
   */
476
  MCU_rows = srcinfo->output_width /
487
  MCU_rows = srcinfo->output_width /
477
    (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
488
    (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
478
489
479
  for (ci = 0; ci < dstinfo->num_components; ci++) {
490
  for (ci = 0; ci < dstinfo->num_components; ci++) {
480
    compptr = dstinfo->comp_info + ci;
491
    compptr = dstinfo->comp_info + ci;
Lines 542-550 Link Here
542
  jpeg_component_info *compptr;
553
  jpeg_component_info *compptr;
543
554
544
  MCU_cols = srcinfo->output_width /
555
  MCU_cols = srcinfo->output_width /
545
    (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
556
    (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
546
  MCU_rows = srcinfo->output_height /
557
  MCU_rows = srcinfo->output_height /
547
    (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
558
    (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
548
559
549
  for (ci = 0; ci < dstinfo->num_components; ci++) {
560
  for (ci = 0; ci < dstinfo->num_components; ci++) {
550
    compptr = dstinfo->comp_info + ci;
561
    compptr = dstinfo->comp_info + ci;
Lines 653-661 Link Here
653
  jpeg_component_info *compptr;
664
  jpeg_component_info *compptr;
654
665
655
  MCU_cols = srcinfo->output_height /
666
  MCU_cols = srcinfo->output_height /
656
    (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size);
667
    (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size);
657
  MCU_rows = srcinfo->output_width /
668
  MCU_rows = srcinfo->output_width /
658
    (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size);
669
    (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size);
659
670
660
  for (ci = 0; ci < dstinfo->num_components; ci++) {
671
  for (ci = 0; ci < dstinfo->num_components; ci++) {
661
    compptr = dstinfo->comp_info + ci;
672
    compptr = dstinfo->comp_info + ci;
Lines 771-777 Link Here
771
 * The routine returns TRUE if the spec string is valid, FALSE if not.
782
 * The routine returns TRUE if the spec string is valid, FALSE if not.
772
 *
783
 *
773
 * The crop spec string should have the format
784
 * The crop spec string should have the format
774
 *	<width>[f]x<height>[f]{+-}<xoffset>{+-}<yoffset>
785
 *	<width>x<height>{+-}<xoffset>{+-}<yoffset>
775
 * where width, height, xoffset, and yoffset are unsigned integers.
786
 * where width, height, xoffset, and yoffset are unsigned integers.
776
 * Each of the elements can be omitted to indicate a default value.
787
 * Each of the elements can be omitted to indicate a default value.
777
 * (A weakness of this style is that it is not possible to omit xoffset
788
 * (A weakness of this style is that it is not possible to omit xoffset
Lines 793-814 Link Here
793
    /* fetch width */
804
    /* fetch width */
794
    if (! jt_read_integer(&spec, &info->crop_width))
805
    if (! jt_read_integer(&spec, &info->crop_width))
795
      return FALSE;
806
      return FALSE;
796
    if (*spec == 'f' || *spec == 'F') {
807
    info->crop_width_set = JCROP_POS;
797
      spec++;
798
      info->crop_width_set = JCROP_FORCE;
799
    } else
800
      info->crop_width_set = JCROP_POS;
801
  }
808
  }
802
  if (*spec == 'x' || *spec == 'X') {
809
  if (*spec == 'x' || *spec == 'X') {	
803
    /* fetch height */
810
    /* fetch height */
804
    spec++;
811
    spec++;
805
    if (! jt_read_integer(&spec, &info->crop_height))
812
    if (! jt_read_integer(&spec, &info->crop_height))
806
      return FALSE;
813
      return FALSE;
807
    if (*spec == 'f' || *spec == 'F') {
814
    info->crop_height_set = JCROP_POS;
808
      spec++;
809
      info->crop_height_set = JCROP_FORCE;
810
    } else
811
      info->crop_height_set = JCROP_POS;
812
  }
815
  }
813
  if (*spec == '+' || *spec == '-') {
816
  if (*spec == '+' || *spec == '-') {
814
    /* fetch xoffset */
817
    /* fetch xoffset */
Lines 897-903 Link Here
897
    info->num_components = srcinfo->num_components;
900
    info->num_components = srcinfo->num_components;
898
901
899
  /* Compute output image dimensions and related values. */
902
  /* Compute output image dimensions and related values. */
903
#if JPEG_LIB_VERSION >= 80
900
  jpeg_core_output_dimensions(srcinfo);
904
  jpeg_core_output_dimensions(srcinfo);
905
#else
906
  srcinfo->output_width = srcinfo->image_width;
907
  srcinfo->output_height = srcinfo->image_height;
908
#endif
901
909
902
  /* Return right away if -perfect is given and transformation is not perfect.
910
  /* Return right away if -perfect is given and transformation is not perfect.
903
   */
911
   */
Lines 905-919 Link Here
905
    if (info->num_components == 1) {
913
    if (info->num_components == 1) {
906
      if (!jtransform_perfect_transform(srcinfo->output_width,
914
      if (!jtransform_perfect_transform(srcinfo->output_width,
907
	  srcinfo->output_height,
915
	  srcinfo->output_height,
908
	  srcinfo->min_DCT_h_scaled_size,
916
	  srcinfo->_min_DCT_h_scaled_size,
909
	  srcinfo->min_DCT_v_scaled_size,
917
	  srcinfo->_min_DCT_v_scaled_size,
910
	  info->transform))
918
	  info->transform))
911
	return FALSE;
919
	return FALSE;
912
    } else {
920
    } else {
913
      if (!jtransform_perfect_transform(srcinfo->output_width,
921
      if (!jtransform_perfect_transform(srcinfo->output_width,
914
	  srcinfo->output_height,
922
	  srcinfo->output_height,
915
	  srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size,
923
	  srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size,
916
	  srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size,
924
	  srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size,
917
	  info->transform))
925
	  info->transform))
918
	return FALSE;
926
	return FALSE;
919
    }
927
    }
Lines 932-957 Link Here
932
    info->output_width = srcinfo->output_height;
940
    info->output_width = srcinfo->output_height;
933
    info->output_height = srcinfo->output_width;
941
    info->output_height = srcinfo->output_width;
934
    if (info->num_components == 1) {
942
    if (info->num_components == 1) {
935
      info->iMCU_sample_width = srcinfo->min_DCT_v_scaled_size;
943
      info->iMCU_sample_width = srcinfo->_min_DCT_v_scaled_size;
936
      info->iMCU_sample_height = srcinfo->min_DCT_h_scaled_size;
944
      info->iMCU_sample_height = srcinfo->_min_DCT_h_scaled_size;
937
    } else {
945
    } else {
938
      info->iMCU_sample_width =
946
      info->iMCU_sample_width =
939
	srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size;
947
	srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
940
      info->iMCU_sample_height =
948
      info->iMCU_sample_height =
941
	srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size;
949
	srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
942
    }
950
    }
943
    break;
951
    break;
944
  default:
952
  default:
945
    info->output_width = srcinfo->output_width;
953
    info->output_width = srcinfo->output_width;
946
    info->output_height = srcinfo->output_height;
954
    info->output_height = srcinfo->output_height;
947
    if (info->num_components == 1) {
955
    if (info->num_components == 1) {
948
      info->iMCU_sample_width = srcinfo->min_DCT_h_scaled_size;
956
      info->iMCU_sample_width = srcinfo->_min_DCT_h_scaled_size;
949
      info->iMCU_sample_height = srcinfo->min_DCT_v_scaled_size;
957
      info->iMCU_sample_height = srcinfo->_min_DCT_v_scaled_size;
950
    } else {
958
    } else {
951
      info->iMCU_sample_width =
959
      info->iMCU_sample_width =
952
	srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size;
960
	srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size;
953
      info->iMCU_sample_height =
961
      info->iMCU_sample_height =
954
	srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size;
962
	srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size;
955
    }
963
    }
956
    break;
964
    break;
957
  }
965
  }
Lines 988-1003 Link Here
988
    else
996
    else
989
      yoffset = info->crop_yoffset;
997
      yoffset = info->crop_yoffset;
990
    /* Now adjust so that upper left corner falls at an iMCU boundary */
998
    /* Now adjust so that upper left corner falls at an iMCU boundary */
991
    if (info->crop_width_set == JCROP_FORCE)
999
    info->output_width =
992
      info->output_width = info->crop_width;
1000
      info->crop_width + (xoffset % info->iMCU_sample_width);
993
    else
1001
    info->output_height =
994
      info->output_width =
1002
      info->crop_height + (yoffset % info->iMCU_sample_height);
995
        info->crop_width + (xoffset % info->iMCU_sample_width);
996
    if (info->crop_height_set == JCROP_FORCE)
997
      info->output_height = info->crop_height;
998
    else
999
      info->output_height =
1000
        info->crop_height + (yoffset % info->iMCU_sample_height);
1001
    /* Save x/y offsets measured in iMCUs */
1003
    /* Save x/y offsets measured in iMCUs */
1002
    info->x_crop_offset = xoffset / info->iMCU_sample_width;
1004
    info->x_crop_offset = xoffset / info->iMCU_sample_width;
1003
    info->y_crop_offset = yoffset / info->iMCU_sample_height;
1005
    info->y_crop_offset = yoffset / info->iMCU_sample_height;
Lines 1020-1026 Link Here
1020
  case JXFORM_FLIP_H:
1022
  case JXFORM_FLIP_H:
1021
    if (info->trim)
1023
    if (info->trim)
1022
      trim_right_edge(info, srcinfo->output_width);
1024
      trim_right_edge(info, srcinfo->output_width);
1023
    if (info->y_crop_offset != 0)
1025
    if (info->y_crop_offset != 0 || info->slow_hflip)
1024
      need_workspace = TRUE;
1026
      need_workspace = TRUE;
1025
    /* do_flip_h_no_crop doesn't need a workspace array */
1027
    /* do_flip_h_no_crop doesn't need a workspace array */
1026
    break;
1028
    break;
Lines 1124-1132 Link Here
1124
  jtemp = dstinfo->image_width;
1126
  jtemp = dstinfo->image_width;
1125
  dstinfo->image_width = dstinfo->image_height;
1127
  dstinfo->image_width = dstinfo->image_height;
1126
  dstinfo->image_height = jtemp;
1128
  dstinfo->image_height = jtemp;
1129
#if JPEG_LIB_VERSION >= 70
1127
  itemp = dstinfo->min_DCT_h_scaled_size;
1130
  itemp = dstinfo->min_DCT_h_scaled_size;
1128
  dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size;
1131
  dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size;
1129
  dstinfo->min_DCT_v_scaled_size = itemp;
1132
  dstinfo->min_DCT_v_scaled_size = itemp;
1133
#endif
1130
1134
1131
  /* Transpose sampling factors */
1135
  /* Transpose sampling factors */
1132
  for (ci = 0; ci < dstinfo->num_components; ci++) {
1136
  for (ci = 0; ci < dstinfo->num_components; ci++) {
Lines 1362-1369 Link Here
1362
  /* Correct the destination's image dimensions as necessary
1366
  /* Correct the destination's image dimensions as necessary
1363
   * for rotate/flip, resize, and crop operations.
1367
   * for rotate/flip, resize, and crop operations.
1364
   */
1368
   */
1369
#if JPEG_LIB_VERSION >= 70
1365
  dstinfo->jpeg_width = info->output_width;
1370
  dstinfo->jpeg_width = info->output_width;
1366
  dstinfo->jpeg_height = info->output_height;
1371
  dstinfo->jpeg_height = info->output_height;
1372
#endif
1367
1373
1368
  /* Transpose destination image parameters */
1374
  /* Transpose destination image parameters */
1369
  switch (info->transform) {
1375
  switch (info->transform) {
Lines 1371-1379 Link Here
1371
  case JXFORM_TRANSVERSE:
1377
  case JXFORM_TRANSVERSE:
1372
  case JXFORM_ROT_90:
1378
  case JXFORM_ROT_90:
1373
  case JXFORM_ROT_270:
1379
  case JXFORM_ROT_270:
1380
#if JPEG_LIB_VERSION < 70
1381
    dstinfo->image_width = info->output_height;
1382
    dstinfo->image_height = info->output_width;
1383
#endif
1374
    transpose_critical_parameters(dstinfo);
1384
    transpose_critical_parameters(dstinfo);
1375
    break;
1385
    break;
1376
  default:
1386
  default:
1387
#if JPEG_LIB_VERSION < 70
1388
    dstinfo->image_width = info->output_width;
1389
    dstinfo->image_height = info->output_height;
1390
#endif
1377
    break;
1391
    break;
1378
  }
1392
  }
1379
1393
Lines 1389-1394 Link Here
1389
      GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
1403
      GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
1390
    /* Suppress output of JFIF marker */
1404
    /* Suppress output of JFIF marker */
1391
    dstinfo->write_JFIF_header = FALSE;
1405
    dstinfo->write_JFIF_header = FALSE;
1406
#if JPEG_LIB_VERSION >= 70
1392
    /* Adjust Exif image parameters */
1407
    /* Adjust Exif image parameters */
1393
    if (dstinfo->jpeg_width != srcinfo->image_width ||
1408
    if (dstinfo->jpeg_width != srcinfo->image_width ||
1394
	dstinfo->jpeg_height != srcinfo->image_height)
1409
	dstinfo->jpeg_height != srcinfo->image_height)
Lines 1396-1401 Link Here
1396
      adjust_exif_parameters(srcinfo->marker_list->data + 6,
1411
      adjust_exif_parameters(srcinfo->marker_list->data + 6,
1397
	srcinfo->marker_list->data_length - 6,
1412
	srcinfo->marker_list->data_length - 6,
1398
	dstinfo->jpeg_width, dstinfo->jpeg_height);
1413
	dstinfo->jpeg_width, dstinfo->jpeg_height);
1414
#endif
1399
  }
1415
  }
1400
1416
1401
  /* Return the appropriate output data set */
1417
  /* Return the appropriate output data set */
Lines 1432-1438 Link Here
1432
	      src_coef_arrays, dst_coef_arrays);
1448
	      src_coef_arrays, dst_coef_arrays);
1433
    break;
1449
    break;
1434
  case JXFORM_FLIP_H:
1450
  case JXFORM_FLIP_H:
1435
    if (info->y_crop_offset != 0)
1451
    if (info->y_crop_offset != 0 || info->slow_hflip)
1436
      do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
1452
      do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
1437
		src_coef_arrays, dst_coef_arrays);
1453
		src_coef_arrays, dst_coef_arrays);
1438
    else
1454
    else

Return to bug 479476