Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / libjpeg / main / jclossy.c
blobecb1a1fa1535a7e02880b9db0dba817fa74a9872
1 /*
2 , $Id$
3 */
5 /*
6 * jclossy.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 lossy JPEG compressor.
15 #define JPEG_INTERNALS
16 #include "jinclude.h"
17 #include "jpeglib.h"
18 #include "jlossy.h"
22 * Initialize for a processing pass.
25 METHODDEF(void)
26 start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
28 j_lossy_c_ptr lossyc = (j_lossy_c_ptr) cinfo->codec;
30 (*lossyc->fdct_start_pass) (cinfo);
31 (*lossyc->coef_start_pass) (cinfo, pass_mode);
36 * Initialize the lossy compression codec.
37 * This is called only once, during master selection.
40 JGLOBAL(void)
41 jinit_lossy_c_codec (j_compress_ptr cinfo)
43 j_lossy_c_ptr lossyc;
45 /* Create subobject in permanent pool */
46 lossyc = (j_lossy_c_ptr)
47 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
48 SIZEOF(jpeg_lossy_c_codec));
49 cinfo->codec = (struct jpeg_c_codec *) lossyc;
51 /* Initialize sub-modules */
53 /* Forward DCT */
54 jinit_forward_dct(cinfo);
55 /* Entropy encoding: either Huffman or arithmetic coding. */
56 if (cinfo->arith_code) {
57 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
58 } else {
59 if (cinfo->process == JPROC_PROGRESSIVE) {
60 #ifdef C_PROGRESSIVE_SUPPORTED
61 jinit_phuff_encoder(cinfo);
62 #else
63 ERREXIT(cinfo, JERR_NOT_COMPILED);
64 #endif
65 } else
66 jinit_shuff_encoder(cinfo);
69 /* Need a full-image coefficient buffer in any multi-pass mode. */
70 jinit_c_coef_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 * jcshuff.c or jcphuff.c and compress_data is assigned in jccoefct.c.
79 lossyc->pub.start_pass = start_pass;