| OLD | NEW |
| 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. |
| 10 * The routines in jcapimin.c will also be needed by a transcoder. | 11 * The routines in jcapimin.c will also be needed by a transcoder. |
| 11 */ | 12 */ |
| 12 | 13 |
| 13 #define JPEG_INTERNALS | 14 #define JPEG_INTERNALS |
| 14 #include "jinclude.h" | 15 #include "jinclude.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 int tblno, ci, coefi; | 70 int tblno, ci, coefi; |
| 70 | 71 |
| 71 /* Safety check to ensure start_compress not called yet. */ | 72 /* Safety check to ensure start_compress not called yet. */ |
| 72 if (dstinfo->global_state != CSTATE_START) | 73 if (dstinfo->global_state != CSTATE_START) |
| 73 ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); | 74 ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); |
| 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 #if JPEG_LIB_VERSION >= 70 |
| 81 dstinfo->jpeg_width = srcinfo->output_width; |
| 82 dstinfo->jpeg_height = srcinfo->output_height; |
| 83 dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size; |
| 84 dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size; |
| 85 #endif |
| 79 /* Initialize all parameters to default values */ | 86 /* Initialize all parameters to default values */ |
| 80 jpeg_set_defaults(dstinfo); | 87 jpeg_set_defaults(dstinfo); |
| 81 /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. | 88 /* 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. | 89 * Fix it to get the right header markers for the image colorspace. |
| 83 */ | 90 */ |
| 84 jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); | 91 jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); |
| 85 dstinfo->data_precision = srcinfo->data_precision; | 92 dstinfo->data_precision = srcinfo->data_precision; |
| 86 dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; | 93 dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; |
| 87 /* Copy the source's quantization tables. */ | 94 /* Copy the source's quantization tables. */ |
| 88 for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { | 95 for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 { | 167 { |
| 161 /* Although we don't actually use input_components for transcoding, | 168 /* Although we don't actually use input_components for transcoding, |
| 162 * jcmaster.c's initial_setup will complain if input_components is 0. | 169 * jcmaster.c's initial_setup will complain if input_components is 0. |
| 163 */ | 170 */ |
| 164 cinfo->input_components = 1; | 171 cinfo->input_components = 1; |
| 165 /* Initialize master control (includes parameter checking/processing) */ | 172 /* Initialize master control (includes parameter checking/processing) */ |
| 166 jinit_c_master_control(cinfo, TRUE /* transcode only */); | 173 jinit_c_master_control(cinfo, TRUE /* transcode only */); |
| 167 | 174 |
| 168 /* Entropy encoding: either Huffman or arithmetic coding. */ | 175 /* Entropy encoding: either Huffman or arithmetic coding. */ |
| 169 if (cinfo->arith_code) { | 176 if (cinfo->arith_code) { |
| 177 #ifdef C_ARITH_CODING_SUPPORTED |
| 178 jinit_arith_encoder(cinfo); |
| 179 #else |
| 170 ERREXIT(cinfo, JERR_ARITH_NOTIMPL); | 180 ERREXIT(cinfo, JERR_ARITH_NOTIMPL); |
| 181 #endif |
| 171 } else { | 182 } else { |
| 172 if (cinfo->progressive_mode) { | 183 if (cinfo->progressive_mode) { |
| 173 #ifdef C_PROGRESSIVE_SUPPORTED | 184 #ifdef C_PROGRESSIVE_SUPPORTED |
| 174 jinit_phuff_encoder(cinfo); | 185 jinit_phuff_encoder(cinfo); |
| 175 #else | 186 #else |
| 176 ERREXIT(cinfo, JERR_NOT_COMPILED); | 187 ERREXIT(cinfo, JERR_NOT_COMPILED); |
| 177 #endif | 188 #endif |
| 178 } else | 189 } else |
| 179 jinit_huff_encoder(cinfo); | 190 jinit_huff_encoder(cinfo); |
| 180 } | 191 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 390 |
| 380 /* Allocate and pre-zero space for dummy DCT blocks. */ | 391 /* Allocate and pre-zero space for dummy DCT blocks. */ |
| 381 buffer = (JBLOCKROW) | 392 buffer = (JBLOCKROW) |
| 382 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 393 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 383 C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); | 394 C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); |
| 384 jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); | 395 jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); |
| 385 for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { | 396 for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { |
| 386 coef->dummy_buffer[i] = buffer + i; | 397 coef->dummy_buffer[i] = buffer + i; |
| 387 } | 398 } |
| 388 } | 399 } |
| OLD | NEW |