| OLD | NEW |
| 1 /* | 1 /* |
| 2 * jdinput.c | 2 * jdinput.c |
| 3 * | 3 * |
| 4 * Copyright (C) 1991-1997, Thomas G. Lane. | 4 * Copyright (C) 1991-1997, Thomas G. Lane. |
| 5 * Modified 2002-2009 by Guido Vollbeding. | |
| 6 * Copyright (C) 2010, D. R. Commander. | 5 * Copyright (C) 2010, D. R. Commander. |
| 7 * This file is part of the Independent JPEG Group's software. | 6 * This file is part of the Independent JPEG Group's software. |
| 8 * For conditions of distribution and use, see the accompanying README file. | 7 * For conditions of distribution and use, see the accompanying README file. |
| 9 * | 8 * |
| 10 * This file contains input control logic for the JPEG decompressor. | 9 * This file contains input control logic for the JPEG decompressor. |
| 11 * These routines are concerned with controlling the decompressor's input | 10 * These routines are concerned with controlling the decompressor's input |
| 12 * processing (marker reading and coefficient decoding). The actual input | 11 * processing (marker reading and coefficient decoding). The actual input |
| 13 * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. | 12 * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. |
| 14 */ | 13 */ |
| 15 | 14 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 31 | 30 |
| 32 | 31 |
| 33 /* Forward declarations */ | 32 /* Forward declarations */ |
| 34 METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); | 33 METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); |
| 35 | 34 |
| 36 | 35 |
| 37 /* | 36 /* |
| 38 * Routines to calculate various quantities related to the size of the image. | 37 * Routines to calculate various quantities related to the size of the image. |
| 39 */ | 38 */ |
| 40 | 39 |
| 41 | |
| 42 #if JPEG_LIB_VERSION >= 80 | |
| 43 /* | |
| 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. | |
| 47 */ | |
| 48 | |
| 49 GLOBAL(void) | |
| 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. | |
| 53 */ | |
| 54 { | |
| 55 #ifdef IDCT_SCALING_SUPPORTED | |
| 56 int ci; | |
| 57 jpeg_component_info *compptr; | |
| 58 | |
| 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; | |
| 92 } | |
| 93 /* Recompute dimensions of components */ | |
| 94 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | |
| 95 ci++, compptr++) { | |
| 96 compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size; | |
| 97 compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size; | |
| 98 } | |
| 99 | |
| 100 #else /* !IDCT_SCALING_SUPPORTED */ | |
| 101 | |
| 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. | |
| 107 */ | |
| 108 | |
| 109 #endif /* IDCT_SCALING_SUPPORTED */ | |
| 110 } | |
| 111 #endif | |
| 112 | |
| 113 | |
| 114 LOCAL(void) | 40 LOCAL(void) |
| 115 initial_setup (j_decompress_ptr cinfo) | 41 initial_setup (j_decompress_ptr cinfo) |
| 116 /* Called once, when first SOS marker is reached */ | 42 /* Called once, when first SOS marker is reached */ |
| 117 { | 43 { |
| 118 int ci; | 44 int ci; |
| 119 jpeg_component_info *compptr; | 45 jpeg_component_info *compptr; |
| 120 | 46 |
| 121 /* Make sure image isn't bigger than I can handle */ | 47 /* Make sure image isn't bigger than I can handle */ |
| 122 if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || | 48 if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || |
| 123 (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) | 49 (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 inputctl->pub.reset_input_controller = reset_input_controller; | 388 inputctl->pub.reset_input_controller = reset_input_controller; |
| 463 inputctl->pub.start_input_pass = start_input_pass; | 389 inputctl->pub.start_input_pass = start_input_pass; |
| 464 inputctl->pub.finish_input_pass = finish_input_pass; | 390 inputctl->pub.finish_input_pass = finish_input_pass; |
| 465 /* Initialize state: can't use reset_input_controller since we don't | 391 /* Initialize state: can't use reset_input_controller since we don't |
| 466 * want to try to reset other modules yet. | 392 * want to try to reset other modules yet. |
| 467 */ | 393 */ |
| 468 inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ | 394 inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ |
| 469 inputctl->pub.eoi_reached = FALSE; | 395 inputctl->pub.eoi_reached = FALSE; |
| 470 inputctl->inheaders = TRUE; | 396 inputctl->inheaders = TRUE; |
| 471 } | 397 } |
| OLD | NEW |