Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / libjpeg / main / jclossls.c
blob08df5ffeaec6f188ea69b6d4097e1ef131ad70aa
1 /*
2 $Id$
3 */
5 /*
6 * jclossls.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 compressor.
15 #define JPEG_INTERNALS
16 #include "jinclude.h"
17 #include "jpeglib.h"
18 #include "jlossls.h"
21 #ifdef C_LOSSLESS_SUPPORTED
24 * Initialize for a processing pass.
27 METHODDEF(void)
28 start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
30 j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
32 (*losslsc->scaler_start_pass) (cinfo);
33 (*losslsc->predict_start_pass) (cinfo);
34 (*losslsc->diff_start_pass) (cinfo, pass_mode);
39 * Initialize the lossless compression codec.
40 * This is called only once, during master selection.
43 JGLOBAL(void)
44 jinit_lossless_c_codec(j_compress_ptr cinfo)
46 j_lossless_c_ptr losslsc;
48 /* Create subobject in permanent pool */
49 losslsc = (j_lossless_c_ptr)
50 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
51 SIZEOF(jpeg_lossless_c_codec));
52 cinfo->codec = (struct jpeg_c_codec *) losslsc;
54 /* Initialize sub-modules */
56 /* Scaler */
57 jinit_c_scaler(cinfo);
59 /* Differencer */
60 jinit_differencer(cinfo);
62 /* Entropy encoding: either Huffman or arithmetic coding. */
63 if (cinfo->arith_code) {
64 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
65 } else {
66 jinit_lhuff_encoder(cinfo);
69 /* Need a full-image difference buffer in any multi-pass mode. */
70 jinit_c_diff_controller(cinfo,
71 (boolean) (cinfo->num_scans > 1 ||
72 cinfo->optimize_coding));
74 /* Initialize method pointers.
76 * Note: entropy_start_pass and entropy_finish_pass are assigned in
77 * jclhuff.c and compress_data is assigned in jcdiffct.c.
79 losslsc->pub.start_pass = start_pass;
82 #endif /* C_LOSSLESS_SUPPORTED */