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.
8 * This file contains the control logic for the lossy JPEG compressor.
11 #define JPEG_INTERNALS
18 * Initialize for a processing pass.
22 start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
24 j_lossy_c_ptr lossyc = (j_lossy_c_ptr) cinfo->codec;
26 (*lossyc->fdct_start_pass) (cinfo);
27 (*lossyc->coef_start_pass) (cinfo, pass_mode);
32 * Initialize the lossy compression codec.
33 * This is called only once, during master selection.
37 jinit_lossy_c_codec (j_compress_ptr cinfo)
41 /* Create subobject in permanent pool */
42 lossyc = (j_lossy_c_ptr)
43 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
44 SIZEOF(jpeg_lossy_c_codec));
45 cinfo->codec = (struct jpeg_c_codec *) lossyc;
47 /* Initialize sub-modules */
50 jinit_forward_dct(cinfo);
51 /* Entropy encoding: either Huffman or arithmetic coding. */
52 if (cinfo->arith_code) {
53 jinit_arith_encoder(cinfo);
55 if (cinfo->process == JPROC_PROGRESSIVE) {
56 #ifdef C_PROGRESSIVE_SUPPORTED
57 jinit_phuff_encoder(cinfo);
59 ERREXIT(cinfo, JERR_NOT_COMPILED);
62 jinit_shuff_encoder(cinfo);
65 /* Need a full-image coefficient buffer in any multi-pass mode. */
66 jinit_c_coef_controller(cinfo,
67 (boolean) (cinfo->num_scans > 1 ||
68 cinfo->optimize_coding));
70 /* Initialize method pointers.
72 * Note: entropy_start_pass and entropy_finish_pass are assigned in
73 * jcshuff.c or jcphuff.c and compress_data is assigned in jccoefct.c.
75 lossyc->pub.start_pass = start_pass;