Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / libjpeg / main / jdlossls.c
blob7d66be7390d0ed437e9599027f8dfdc68b491cee
1 /*
2 $Id$
3 */
5 /*
6 * jdlossls.c
8 * Copyright (C) 1998, Thomas G. Lane.
9 * This file is part of the Independent JPEG Group's software.
10 * For conditions of distribution and use, see the accompanying README file.
12 * This file contains the control logic for the lossless JPEG decompressor.
15 #define JPEG_INTERNALS
16 #include "jinclude.h"
17 #include "jpeglib.h"
18 #include "jlossls.h"
21 #ifdef D_LOSSLESS_SUPPORTED
24 * Compute output image dimensions and related values.
27 METHODDEF(void)
28 calc_output_dimensions (j_decompress_ptr cinfo)
30 /* Hardwire it to "no scaling" */
31 cinfo->output_width = cinfo->image_width;
32 cinfo->output_height = cinfo->image_height;
33 /* jdinput.c has already initialized codec_data_unit to 1,
34 * and has computed unscaled downsampled_width and downsampled_height.
40 * Initialize for an input processing pass.
43 METHODDEF(void)
44 start_input_pass (j_decompress_ptr cinfo)
46 j_lossless_d_ptr losslsd = (j_lossless_d_ptr) cinfo->codec;
48 (*losslsd->entropy_start_pass) (cinfo);
49 (*losslsd->predict_start_pass) (cinfo);
50 (*losslsd->scaler_start_pass) (cinfo);
51 (*losslsd->diff_start_input_pass) (cinfo);
56 * Initialize the lossless decompression codec.
57 * This is called only once, during master selection.
60 JGLOBAL(void)
61 jinit_lossless_d_codec(j_decompress_ptr cinfo)
63 j_lossless_d_ptr losslsd;
64 boolean use_c_buffer;
66 /* Create subobject in permanent pool */
67 losslsd = (j_lossless_d_ptr)
68 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
69 SIZEOF(jpeg_lossless_d_codec));
70 cinfo->codec = (struct jpeg_d_codec *) losslsd;
72 /* Initialize sub-modules */
73 /* Entropy decoding: either Huffman or arithmetic coding. */
74 if (cinfo->arith_code) {
75 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
76 } else {
77 jinit_lhuff_decoder(cinfo);
80 /* Undifferencer */
81 jinit_undifferencer(cinfo);
83 /* Scaler */
84 jinit_d_scaler(cinfo);
86 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
87 jinit_d_diff_controller(cinfo, use_c_buffer);
89 /* Initialize method pointers.
91 * Note: consume_data, start_output_pass and decompress_data are
92 * assigned in jddiffct.c.
94 losslsd->pub.calc_output_dimensions = calc_output_dimensions;
95 losslsd->pub.start_input_pass = start_input_pass;
98 #endif /* D_LOSSLESS_SUPPORTED */