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
22 * Initialize for a processing pass.
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.
41 jinit_lossy_c_codec (j_compress_ptr cinfo
)
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 */
54 jinit_forward_dct(cinfo
);
55 /* Entropy encoding: either Huffman or arithmetic coding. */
56 if (cinfo
->arith_code
) {
57 ERREXIT(cinfo
, JERR_ARITH_NOTIMPL
);
59 if (cinfo
->process
== JPROC_PROGRESSIVE
) {
60 #ifdef C_PROGRESSIVE_SUPPORTED
61 jinit_phuff_encoder(cinfo
);
63 ERREXIT(cinfo
, JERR_NOT_COMPILED
);
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
;