1 /* |
1 /* |
2 * jctrans.c |
2 * jctrans.c |
3 * |
3 * |
4 * Copyright (C) 1995-1998, Thomas G. Lane. |
4 * Copyright (C) 1995-1998, Thomas G. Lane. |
|
5 * Modified 2000-2009 by Guido Vollbeding. |
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 * |
8 * This file contains library routines for transcoding compression, |
9 * This file contains library routines for transcoding compression, |
9 * that is, writing raw DCT coefficient arrays to an output JPEG file. |
10 * that is, writing raw DCT coefficient arrays to an output JPEG file. |
74 /* Copy fundamental image dimensions */ |
75 /* Copy fundamental image dimensions */ |
75 dstinfo->image_width = srcinfo->image_width; |
76 dstinfo->image_width = srcinfo->image_width; |
76 dstinfo->image_height = srcinfo->image_height; |
77 dstinfo->image_height = srcinfo->image_height; |
77 dstinfo->input_components = srcinfo->num_components; |
78 dstinfo->input_components = srcinfo->num_components; |
78 dstinfo->in_color_space = srcinfo->jpeg_color_space; |
79 dstinfo->in_color_space = srcinfo->jpeg_color_space; |
|
80 dstinfo->jpeg_width = srcinfo->output_width; |
|
81 dstinfo->jpeg_height = srcinfo->output_height; |
|
82 dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size; |
|
83 dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size; |
79 /* Initialize all parameters to default values */ |
84 /* Initialize all parameters to default values */ |
80 jpeg_set_defaults(dstinfo); |
85 jpeg_set_defaults(dstinfo); |
81 /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. |
86 /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. |
82 * Fix it to get the right header markers for the image colorspace. |
87 * Fix it to get the right header markers for the image colorspace. |
83 */ |
88 */ |
156 |
161 |
157 LOCAL(void) |
162 LOCAL(void) |
158 transencode_master_selection (j_compress_ptr cinfo, |
163 transencode_master_selection (j_compress_ptr cinfo, |
159 jvirt_barray_ptr * coef_arrays) |
164 jvirt_barray_ptr * coef_arrays) |
160 { |
165 { |
161 /* Although we don't actually use input_components for transcoding, |
|
162 * jcmaster.c's initial_setup will complain if input_components is 0. |
|
163 */ |
|
164 cinfo->input_components = 1; |
|
165 /* Initialize master control (includes parameter checking/processing) */ |
166 /* Initialize master control (includes parameter checking/processing) */ |
166 jinit_c_master_control(cinfo, TRUE /* transcode only */); |
167 jinit_c_master_control(cinfo, TRUE /* transcode only */); |
167 |
168 |
168 /* Entropy encoding: either Huffman or arithmetic coding. */ |
169 /* Entropy encoding: either Huffman or arithmetic coding. */ |
169 if (cinfo->arith_code) { |
170 if (cinfo->arith_code) |
170 ERREXIT(cinfo, JERR_ARITH_NOTIMPL); |
171 jinit_arith_encoder(cinfo); |
171 } else { |
172 else { |
172 if (cinfo->progressive_mode) { |
173 jinit_huff_encoder(cinfo); |
173 #ifdef C_PROGRESSIVE_SUPPORTED |
|
174 jinit_phuff_encoder(cinfo); |
|
175 #else |
|
176 ERREXIT(cinfo, JERR_NOT_COMPILED); |
|
177 #endif |
|
178 } else |
|
179 jinit_huff_encoder(cinfo); |
|
180 } |
174 } |
181 |
175 |
182 /* We need a special coefficient buffer controller. */ |
176 /* We need a special coefficient buffer controller. */ |
183 transencode_coef_controller(cinfo, coef_arrays); |
177 transencode_coef_controller(cinfo, coef_arrays); |
184 |
178 |