1 /*
2  * jlossls.h
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 include file contains common declarations for the lossless JPEG
9  * codec modules.
10  */
11 
12 #ifndef JLOSSLS_H
13 #define JLOSSLS_H
14 
15 
16 /*
17  * Table H.1: Predictors for lossless coding.
18  */
19 
20 #define PREDICTOR1	Ra
21 #define PREDICTOR2	Rb
22 #define PREDICTOR3	Rc
23 #define PREDICTOR4	(int) ((IJG_INT32) Ra + (IJG_INT32) Rb - (IJG_INT32) Rc)
24 #define PREDICTOR5	(int) ((IJG_INT32) Ra + RIGHT_SHIFT((IJG_INT32) Rb - (IJG_INT32) Rc, 1))
25 #define PREDICTOR6	(int) ((IJG_INT32) Rb + RIGHT_SHIFT((IJG_INT32) Ra - (IJG_INT32) Rc, 1))
26 #define PREDICTOR7	(int) RIGHT_SHIFT((IJG_INT32) Ra + (IJG_INT32) Rb, 1)
27 
28 
29 typedef JMETHOD(void, predict_difference_method_ptr,
30 		(j_compress_ptr cinfo, int ci,
31 		 JSAMPROW input_buf, JSAMPROW prev_row,
32 		 JDIFFROW diff_buf, JDIMENSION width));
33 
34 typedef JMETHOD(void, scaler_method_ptr,
35 		(j_compress_ptr cinfo, int ci,
36 		 JSAMPROW input_buf, JSAMPROW output_buf,
37 		 JDIMENSION width));
38 
39 /* Lossless-specific compression codec (compressor proper) */
40 typedef struct {
41   struct jpeg_c_codec pub; /* public fields */
42 
43 
44   /* Difference buffer control */
45   JMETHOD(void, diff_start_pass, (j_compress_ptr cinfo,
46 				  J_BUF_MODE pass_mode));
47 
48   /* Pointer to data which is private to diff controller */
49   void *diff_private;
50 
51 
52   /* Entropy encoding */
53   JMETHOD(JDIMENSION, entropy_encode_mcus, (j_compress_ptr cinfo,
54 					    JDIFFIMAGE diff_buf,
55 					    JDIMENSION MCU_row_num,
56 					    JDIMENSION MCU_col_num,
57 					    JDIMENSION nMCU));
58 
59   /* Pointer to data which is private to entropy module */
60   void *entropy_private;
61 
62 
63   /* Prediction, differencing */
64   JMETHOD(void, predict_start_pass, (j_compress_ptr cinfo));
65 
66   /* It is useful to allow each component to have a separate diff method. */
67   predict_difference_method_ptr predict_difference[MAX_COMPONENTS];
68 
69   /* Pointer to data which is private to predictor module */
70   void *pred_private;
71 
72   /* Sample scaling */
73   JMETHOD(void, scaler_start_pass, (j_compress_ptr cinfo));
74   JMETHOD(void, scaler_scale, (j_compress_ptr cinfo,
75 			       JSAMPROW input_buf, JSAMPROW output_buf,
76 			       JDIMENSION width));
77 
78   /* Pointer to data which is private to scaler module */
79   void *scaler_private;
80 
81 } jpeg_lossless_c_codec;
82 
83 typedef jpeg_lossless_c_codec * j_lossless_c_ptr;
84 
85 
86 typedef JMETHOD(void, predict_undifference_method_ptr,
87 		(j_decompress_ptr cinfo, int comp_index,
88 		 JDIFFROW diff_buf, JDIFFROW prev_row,
89 		 JDIFFROW undiff_buf, JDIMENSION width));
90 
91 /* Lossless-specific decompression codec (decompressor proper) */
92 typedef struct {
93   struct jpeg_d_codec pub; /* public fields */
94 
95 
96   /* Difference buffer control */
97   JMETHOD(void, diff_start_input_pass, (j_decompress_ptr cinfo));
98 
99   /* Pointer to data which is private to diff controller */
100   void *diff_private;
101 
102 
103   /* Entropy decoding */
104   JMETHOD(void, entropy_start_pass, (j_decompress_ptr cinfo));
105   JMETHOD(boolean, entropy_process_restart, (j_decompress_ptr cinfo));
106   JMETHOD(JDIMENSION, entropy_decode_mcus, (j_decompress_ptr cinfo,
107 					    JDIFFIMAGE diff_buf,
108 					    JDIMENSION MCU_row_num,
109 					    JDIMENSION MCU_col_num,
110 					    JDIMENSION nMCU));
111 
112   /* Pointer to data which is private to entropy module */
113   void *entropy_private;
114 
115 
116   /* Prediction, undifferencing */
117   JMETHOD(void, predict_start_pass, (j_decompress_ptr cinfo));
118   JMETHOD(void, predict_process_restart, (j_decompress_ptr cinfo));
119 
120   /* It is useful to allow each component to have a separate undiff method. */
121   predict_undifference_method_ptr predict_undifference[MAX_COMPONENTS];
122 
123   /* Pointer to data which is private to predictor module */
124   void *pred_private;
125 
126   /* Sample scaling */
127   JMETHOD(void, scaler_start_pass, (j_decompress_ptr cinfo));
128   JMETHOD(void, scaler_scale, (j_decompress_ptr cinfo,
129 			       JDIFFROW diff_buf, JSAMPROW output_buf,
130 			       JDIMENSION width));
131 
132   /* Pointer to data which is private to scaler module */
133   void *scaler_private;
134 
135 } jpeg_lossless_d_codec;
136 
137 typedef jpeg_lossless_d_codec * j_lossless_d_ptr;
138 
139 
140 /* Compression module initialization routines */
141 EXTERN(void) jinit_lossless_c_codec JPP((j_compress_ptr cinfo));
142 EXTERN(void) jinit_lhuff_encoder JPP((j_compress_ptr cinfo));
143 EXTERN(void) jinit_differencer JPP((j_compress_ptr cinfo));
144 EXTERN(void) jinit_c_scaler JPP((j_compress_ptr cinfo));
145 /* Decompression module initialization routines */
146 EXTERN(void) jinit_lossless_d_codec JPP((j_decompress_ptr cinfo));
147 EXTERN(void) jinit_lhuff_decoder JPP((j_decompress_ptr cinfo));
148 EXTERN(void) jinit_undifferencer JPP((j_decompress_ptr cinfo));
149 EXTERN(void) jinit_d_scaler JPP((j_decompress_ptr cinfo));
150 
151 #endif /* JLOSSLS_H */
152