1 /* 2 * jdlossls.c 3 * 4 * Copyright (C) 1998, Thomas G. Lane. 5 * This file is part of the Independent JPEG Group's software. 6 * For conditions of distribution and use, see the accompanying README file. 7 * 8 * This file contains the control logic for the lossless JPEG decompressor. 9 */ 10 11 #define JPEG_INTERNALS 12 #include "jinclude16.h" 13 #include "jpeglib16.h" 14 #include "jlossls16.h" 15 16 17 #ifdef D_LOSSLESS_SUPPORTED 18 19 /* 20 * Compute output image dimensions and related values. 21 */ 22 23 METHODDEF(void) calc_output_dimensions(j_decompress_ptr cinfo)24calc_output_dimensions (j_decompress_ptr cinfo) 25 { 26 /* Hardwire it to "no scaling" */ 27 cinfo->output_width = cinfo->image_width; 28 cinfo->output_height = cinfo->image_height; 29 /* jdinput.c has already initialized codec_data_unit to 1, 30 * and has computed unscaled downsampled_width and downsampled_height. 31 */ 32 } 33 34 35 /* 36 * Initialize for an input processing pass. 37 */ 38 39 METHODDEF(void) start_input_pass(j_decompress_ptr cinfo)40start_input_pass (j_decompress_ptr cinfo) 41 { 42 j_lossless_d_ptr losslsd = (j_lossless_d_ptr) cinfo->codec; 43 44 (*losslsd->entropy_start_pass) (cinfo); 45 (*losslsd->predict_start_pass) (cinfo); 46 (*losslsd->scaler_start_pass) (cinfo); 47 (*losslsd->diff_start_input_pass) (cinfo); 48 } 49 50 51 /* 52 * Initialize the lossless decompression codec. 53 * This is called only once, during master selection. 54 */ 55 56 GLOBAL(void) jinit_lossless_d_codec(j_decompress_ptr cinfo)57jinit_lossless_d_codec(j_decompress_ptr cinfo) 58 { 59 j_lossless_d_ptr losslsd; 60 boolean use_c_buffer; 61 62 /* Create subobject in permanent pool */ 63 losslsd = (j_lossless_d_ptr) 64 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 65 SIZEOF(jpeg_lossless_d_codec)); 66 cinfo->codec = (struct jpeg_d_codec *) losslsd; 67 68 /* Initialize sub-modules */ 69 /* Entropy decoding: either Huffman or arithmetic coding. */ 70 if (cinfo->arith_code) { 71 #ifdef WITH_ARITHMETIC_PATCH 72 jinit_arith_decoder(cinfo); 73 #else 74 ERREXIT(cinfo, JERR_ARITH_NOTIMPL); 75 #endif 76 } else { 77 jinit_lhuff_decoder(cinfo); 78 } 79 80 /* Undifferencer */ 81 jinit_undifferencer(cinfo); 82 83 /* Scaler */ 84 jinit_d_scaler(cinfo); 85 86 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; 87 jinit_d_diff_controller(cinfo, use_c_buffer); 88 89 /* Initialize method pointers. 90 * 91 * Note: consume_data, start_output_pass and decompress_data are 92 * assigned in jddiffct.c. 93 */ 94 losslsd->pub.calc_output_dimensions = calc_output_dimensions; 95 losslsd->pub.start_input_pass = start_input_pass; 96 } 97 98 #endif /* D_LOSSLESS_SUPPORTED */ 99