38
38
* Routines to calculate various quantities related to the size of the image.
42
#if JPEG_LIB_VERSION >= 80
44
* Compute output image dimensions and related values.
45
* NOTE: this is exported for possible use by application.
46
* Hence it mustn't do anything that can't be done twice.
50
jpeg_core_output_dimensions (j_decompress_ptr cinfo)
51
/* Do computations that are needed before master selection phase.
52
* This function is used for transcoding and full decompression.
55
#ifdef IDCT_SCALING_SUPPORTED
57
jpeg_component_info *compptr;
59
/* Compute actual output image dimensions and DCT scaling choices. */
60
if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) {
61
/* Provide 1/block_size scaling */
62
cinfo->output_width = (JDIMENSION)
63
jdiv_round_up((long) cinfo->image_width, (long) cinfo->block_size);
64
cinfo->output_height = (JDIMENSION)
65
jdiv_round_up((long) cinfo->image_height, (long) cinfo->block_size);
66
cinfo->min_DCT_h_scaled_size = 1;
67
cinfo->min_DCT_v_scaled_size = 1;
68
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) {
69
/* Provide 2/block_size scaling */
70
cinfo->output_width = (JDIMENSION)
71
jdiv_round_up((long) cinfo->image_width * 2L, (long) cinfo->block_size);
72
cinfo->output_height = (JDIMENSION)
73
jdiv_round_up((long) cinfo->image_height * 2L, (long) cinfo->block_size);
74
cinfo->min_DCT_h_scaled_size = 2;
75
cinfo->min_DCT_v_scaled_size = 2;
76
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) {
77
/* Provide 4/block_size scaling */
78
cinfo->output_width = (JDIMENSION)
79
jdiv_round_up((long) cinfo->image_width * 4L, (long) cinfo->block_size);
80
cinfo->output_height = (JDIMENSION)
81
jdiv_round_up((long) cinfo->image_height * 4L, (long) cinfo->block_size);
82
cinfo->min_DCT_h_scaled_size = 4;
83
cinfo->min_DCT_v_scaled_size = 4;
84
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) {
85
/* Provide 8/block_size scaling */
86
cinfo->output_width = (JDIMENSION)
87
jdiv_round_up((long) cinfo->image_width * 8L, (long) cinfo->block_size);
88
cinfo->output_height = (JDIMENSION)
89
jdiv_round_up((long) cinfo->image_height * 8L, (long) cinfo->block_size);
90
cinfo->min_DCT_h_scaled_size = 8;
91
cinfo->min_DCT_v_scaled_size = 8;
93
/* Recompute dimensions of components */
94
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
96
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size;
97
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size;
100
#else /* !IDCT_SCALING_SUPPORTED */
102
/* Hardwire it to "no scaling" */
103
cinfo->output_width = cinfo->image_width;
104
cinfo->output_height = cinfo->image_height;
105
/* jdinput.c has already initialized DCT_scaled_size,
106
* and has computed unscaled downsampled_width and downsampled_height.
109
#endif /* IDCT_SCALING_SUPPORTED */
115
42
initial_setup (j_decompress_ptr cinfo)
116
43
/* Called once, when first SOS marker is reached */