]> Creatis software - gdcm.git/blob - src/gdcmjpeg/jclossy.c
ENH: Final -hopefully- change to jpeg lib. In order to match ITK structure, and be...
[gdcm.git] / src / gdcmjpeg / jclossy.c
1 /*
2  * jclossy.c
3  *
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.
7  *
8  * This file contains the control logic for the lossy JPEG compressor.
9  */
10
11 #define JPEG_INTERNALS
12 #include "jinclude.h"
13 #include "jpeglib.h"
14 #include "jlossy.h"
15
16
17 /*
18  * Initialize for a processing pass.
19  */
20
21 METHODDEF(void)
22 start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
23 {
24   j_lossy_c_ptr lossyc = (j_lossy_c_ptr) cinfo->codec;
25
26   (*lossyc->fdct_start_pass) (cinfo);
27   (*lossyc->coef_start_pass) (cinfo, pass_mode);
28 }
29
30
31 /*
32  * Initialize the lossy compression codec.
33  * This is called only once, during master selection.
34  */
35
36 GLOBAL(void)
37 jinit_lossy_c_codec (j_compress_ptr cinfo)
38 {
39   j_lossy_c_ptr lossyc;
40
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;
46
47   /* Initialize sub-modules */
48
49   /* Forward DCT */
50   jinit_forward_dct(cinfo);
51   /* Entropy encoding: either Huffman or arithmetic coding. */
52   if (cinfo->arith_code) {
53     jinit_arith_encoder(cinfo);
54   } else {
55     if (cinfo->process == JPROC_PROGRESSIVE) {
56 #ifdef C_PROGRESSIVE_SUPPORTED
57       jinit_phuff_encoder(cinfo);
58 #else
59       ERREXIT(cinfo, JERR_NOT_COMPILED);
60 #endif
61     } else
62       jinit_shuff_encoder(cinfo);
63   }
64
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));
69
70   /* Initialize method pointers.
71    *
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.
74    */
75   lossyc->pub.start_pass = start_pass;
76 }