]> Creatis software - gdcm.git/blob - src/gdcmjpeg/jclossls.c
ENH: Final -hopefully- change to jpeg lib. In order to match ITK structure, and be...
[gdcm.git] / src / gdcmjpeg / jclossls.c
1 /*
2  * jclossls.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 lossless JPEG compressor.
9  */
10
11 #define JPEG_INTERNALS
12 #include "jinclude.h"
13 #include "jpeglib.h"
14 #include "jlossls.h"
15
16
17 #ifdef C_LOSSLESS_SUPPORTED
18
19 /*
20  * Initialize for a processing pass.
21  */
22
23 METHODDEF(void)
24 start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
25 {
26   j_lossless_c_ptr losslsc = (j_lossless_c_ptr) cinfo->codec;
27
28   (*losslsc->scaler_start_pass) (cinfo);
29   (*losslsc->predict_start_pass) (cinfo);
30   (*losslsc->diff_start_pass) (cinfo, pass_mode);
31 }
32
33
34 /*
35  * Initialize the lossless compression codec.
36  * This is called only once, during master selection.
37  */
38
39 GLOBAL(void) 
40 jinit_lossless_c_codec(j_compress_ptr cinfo)
41 {
42   j_lossless_c_ptr losslsc;
43
44   /* Create subobject in permanent pool */
45   losslsc = (j_lossless_c_ptr)
46     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
47         SIZEOF(jpeg_lossless_c_codec));
48   cinfo->codec = (struct jpeg_c_codec *) losslsc;
49
50   /* Initialize sub-modules */
51
52   /* Scaler */
53   jinit_c_scaler(cinfo);
54
55   /* Differencer */
56   jinit_differencer(cinfo);
57
58   /* Entropy encoding: either Huffman or arithmetic coding. */
59   if (cinfo->arith_code) {
60     jinit_arith_encoder(cinfo);
61   } else {
62     jinit_lhuff_encoder(cinfo);
63   }
64
65   /* Need a full-image difference buffer in any multi-pass mode. */
66   jinit_c_diff_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    * jclhuff.c and compress_data is assigned in jcdiffct.c.
74    */
75   losslsc->pub.start_pass = start_pass;
76 }
77
78 #endif /* C_LOSSLESS_SUPPORTED */