/src/libjpeg-turbo.main/src/jdlossls.c
Line | Count | Source |
1 | | /* |
2 | | * jdlossls.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1998, Thomas G. Lane. |
6 | | * Lossless JPEG Modifications: |
7 | | * Copyright (C) 1999, Ken Murchison. |
8 | | * libjpeg-turbo Modifications: |
9 | | * Copyright (C) 2022, 2024, 2026, D. R. Commander. |
10 | | * For conditions of distribution and use, see the accompanying README.ijg |
11 | | * file. |
12 | | * |
13 | | * This file contains prediction, sample undifferencing, point transform, and |
14 | | * sample scaling routines for the lossless JPEG decompressor. |
15 | | */ |
16 | | |
17 | | #define JPEG_INTERNALS |
18 | | #include "jinclude.h" |
19 | | #include "jpeglib.h" |
20 | | #include "jlossls.h" |
21 | | |
22 | | #ifdef D_LOSSLESS_SUPPORTED |
23 | | |
24 | | |
25 | | /**************** Sample undifferencing (reconstruction) *****************/ |
26 | | |
27 | | /* |
28 | | * In order to avoid a performance penalty for checking which predictor is |
29 | | * being used and which row is being processed for each call of the |
30 | | * undifferencer, and to promote optimization, we have separate undifferencing |
31 | | * functions for each predictor selection value. |
32 | | * |
33 | | * We are able to avoid duplicating source code by implementing the predictors |
34 | | * and undifferencers as macros. Each of the undifferencing functions is |
35 | | * simply a wrapper around an UNDIFFERENCE macro with the appropriate PREDICTOR |
36 | | * macro passed as an argument. |
37 | | */ |
38 | | |
39 | | /* Predictor for the first column of the first row: 2^(P-Pt-1) */ |
40 | | #define INITIAL_PREDICTORx (1 << (cinfo->data_precision - cinfo->Al - 1)) |
41 | | |
42 | | /* Predictor for the first column of the remaining rows: Rb */ |
43 | | #define INITIAL_PREDICTOR2 prev_row[0] |
44 | | |
45 | | |
46 | | /* |
47 | | * 1-Dimensional undifferencer routine. |
48 | | * |
49 | | * This macro implements the 1-D horizontal predictor (1). INITIAL_PREDICTOR |
50 | | * is used as the special case predictor for the first column, which must be |
51 | | * either INITIAL_PREDICTOR2 or INITIAL_PREDICTORx. The remaining samples |
52 | | * use PREDICTOR1. |
53 | | * |
54 | | * The reconstructed sample is supposed to be calculated modulo 2^16, so we |
55 | | * logically AND the result with 0xFFFF. |
56 | | */ |
57 | | |
58 | | #define UNDIFFERENCE_1D(INITIAL_PREDICTOR) \ |
59 | 4.67M | int Ra; \ |
60 | 4.67M | \ |
61 | 4.67M | Ra = (*diff_buf++ + INITIAL_PREDICTOR) & 0xFFFF; \ |
62 | 4.67M | *undiff_buf++ = Ra; \ |
63 | 4.67M | \ |
64 | 27.1M | while (--width) { \ |
65 | 22.4M | Ra = (*diff_buf++ + PREDICTOR1) & 0xFFFF; \ |
66 | 22.4M | *undiff_buf++ = Ra; \ |
67 | 22.4M | } |
68 | | |
69 | | |
70 | | /* |
71 | | * 2-Dimensional undifferencer routine. |
72 | | * |
73 | | * This macro implements the 2-D horizontal predictors (#2-7). PREDICTOR2 is |
74 | | * used as the special case predictor for the first column. The remaining |
75 | | * samples use PREDICTOR, which is a function of Ra, Rb, and Rc. |
76 | | * |
77 | | * Because prev_row and output_buf may point to the same storage area (in an |
78 | | * interleaved image with Vi=1, for example), we must take care to buffer Rb/Rc |
79 | | * before writing the current reconstructed sample value into output_buf. |
80 | | * |
81 | | * The reconstructed sample is supposed to be calculated modulo 2^16, so we |
82 | | * logically AND the result with 0xFFFF. |
83 | | */ |
84 | | |
85 | | #define UNDIFFERENCE_2D(PREDICTOR) \ |
86 | 2.54M | int Ra, Rb, Rc; \ |
87 | 2.54M | \ |
88 | 2.54M | Rb = *prev_row++; \ |
89 | 2.54M | Ra = (*diff_buf++ + PREDICTOR2) & 0xFFFF; \ |
90 | 2.54M | *undiff_buf++ = Ra; \ |
91 | 2.54M | \ |
92 | 19.3M | while (--width) { \ |
93 | 16.7M | Rc = Rb; \ |
94 | 16.7M | Rb = *prev_row++; \ |
95 | 16.7M | Ra = (*diff_buf++ + PREDICTOR) & 0xFFFF; \ |
96 | 16.7M | *undiff_buf++ = Ra; \ |
97 | 16.7M | } |
98 | | |
99 | | |
100 | | /* |
101 | | * Undifferencers for the second and subsequent rows in a scan or restart |
102 | | * interval. The first sample in the row is undifferenced using the vertical |
103 | | * predictor (2). The rest of the samples are undifferenced using the |
104 | | * predictor specified in the scan header. |
105 | | */ |
106 | | |
107 | | METHODDEF(void) |
108 | | jpeg_undifference1(j_decompress_ptr cinfo, int comp_index, |
109 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
110 | | JDIFFROW undiff_buf, JDIMENSION width) |
111 | 1.25M | { |
112 | 1.25M | UNDIFFERENCE_1D(INITIAL_PREDICTOR2); |
113 | 1.25M | } jdlossls-8.c:jpeg_undifference1 Line | Count | Source | 111 | 943k | { | 112 | 943k | UNDIFFERENCE_1D(INITIAL_PREDICTOR2); | 113 | 943k | } |
jdlossls-12.c:jpeg_undifference1 Line | Count | Source | 111 | 111k | { | 112 | 111k | UNDIFFERENCE_1D(INITIAL_PREDICTOR2); | 113 | 111k | } |
jdlossls-16.c:jpeg_undifference1 Line | Count | Source | 111 | 200k | { | 112 | 200k | UNDIFFERENCE_1D(INITIAL_PREDICTOR2); | 113 | 200k | } |
|
114 | | |
115 | | METHODDEF(void) |
116 | | jpeg_undifference2(j_decompress_ptr cinfo, int comp_index, |
117 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
118 | | JDIFFROW undiff_buf, JDIMENSION width) |
119 | 278k | { |
120 | 278k | UNDIFFERENCE_2D(PREDICTOR2); |
121 | 278k | (void)(Rc); |
122 | 278k | } jdlossls-8.c:jpeg_undifference2 Line | Count | Source | 119 | 14.8k | { | 120 | 14.8k | UNDIFFERENCE_2D(PREDICTOR2); | 121 | 14.8k | (void)(Rc); | 122 | 14.8k | } |
jdlossls-12.c:jpeg_undifference2 Line | Count | Source | 119 | 153k | { | 120 | 153k | UNDIFFERENCE_2D(PREDICTOR2); | 121 | 153k | (void)(Rc); | 122 | 153k | } |
jdlossls-16.c:jpeg_undifference2 Line | Count | Source | 119 | 110k | { | 120 | 110k | UNDIFFERENCE_2D(PREDICTOR2); | 121 | 110k | (void)(Rc); | 122 | 110k | } |
|
123 | | |
124 | | METHODDEF(void) |
125 | | jpeg_undifference3(j_decompress_ptr cinfo, int comp_index, |
126 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
127 | | JDIFFROW undiff_buf, JDIMENSION width) |
128 | 1.45M | { |
129 | 1.45M | UNDIFFERENCE_2D(PREDICTOR3); |
130 | 1.45M | } jdlossls-8.c:jpeg_undifference3 Line | Count | Source | 128 | 1.20M | { | 129 | 1.20M | UNDIFFERENCE_2D(PREDICTOR3); | 130 | 1.20M | } |
jdlossls-12.c:jpeg_undifference3 Line | Count | Source | 128 | 164k | { | 129 | 164k | UNDIFFERENCE_2D(PREDICTOR3); | 130 | 164k | } |
jdlossls-16.c:jpeg_undifference3 Line | Count | Source | 128 | 80.1k | { | 129 | 80.1k | UNDIFFERENCE_2D(PREDICTOR3); | 130 | 80.1k | } |
|
131 | | |
132 | | METHODDEF(void) |
133 | | jpeg_undifference4(j_decompress_ptr cinfo, int comp_index, |
134 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
135 | | JDIFFROW undiff_buf, JDIMENSION width) |
136 | 227k | { |
137 | 227k | UNDIFFERENCE_2D(PREDICTOR4); |
138 | 227k | } jdlossls-8.c:jpeg_undifference4 Line | Count | Source | 136 | 189k | { | 137 | 189k | UNDIFFERENCE_2D(PREDICTOR4); | 138 | 189k | } |
jdlossls-12.c:jpeg_undifference4 Line | Count | Source | 136 | 35.8k | { | 137 | 35.8k | UNDIFFERENCE_2D(PREDICTOR4); | 138 | 35.8k | } |
jdlossls-16.c:jpeg_undifference4 Line | Count | Source | 136 | 2.04k | { | 137 | 2.04k | UNDIFFERENCE_2D(PREDICTOR4); | 138 | 2.04k | } |
|
139 | | |
140 | | METHODDEF(void) |
141 | | jpeg_undifference5(j_decompress_ptr cinfo, int comp_index, |
142 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
143 | | JDIFFROW undiff_buf, JDIMENSION width) |
144 | 211k | { |
145 | 211k | UNDIFFERENCE_2D(PREDICTOR5); |
146 | 211k | } jdlossls-8.c:jpeg_undifference5 Line | Count | Source | 144 | 16.8k | { | 145 | 16.8k | UNDIFFERENCE_2D(PREDICTOR5); | 146 | 16.8k | } |
jdlossls-12.c:jpeg_undifference5 Line | Count | Source | 144 | 67.9k | { | 145 | 67.9k | UNDIFFERENCE_2D(PREDICTOR5); | 146 | 67.9k | } |
jdlossls-16.c:jpeg_undifference5 Line | Count | Source | 144 | 126k | { | 145 | 126k | UNDIFFERENCE_2D(PREDICTOR5); | 146 | 126k | } |
|
147 | | |
148 | | METHODDEF(void) |
149 | | jpeg_undifference6(j_decompress_ptr cinfo, int comp_index, |
150 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
151 | | JDIFFROW undiff_buf, JDIMENSION width) |
152 | 140k | { |
153 | 140k | UNDIFFERENCE_2D(PREDICTOR6); |
154 | 140k | } jdlossls-8.c:jpeg_undifference6 Line | Count | Source | 152 | 745 | { | 153 | 745 | UNDIFFERENCE_2D(PREDICTOR6); | 154 | 745 | } |
jdlossls-12.c:jpeg_undifference6 Line | Count | Source | 152 | 128k | { | 153 | 128k | UNDIFFERENCE_2D(PREDICTOR6); | 154 | 128k | } |
jdlossls-16.c:jpeg_undifference6 Line | Count | Source | 152 | 11.8k | { | 153 | 11.8k | UNDIFFERENCE_2D(PREDICTOR6); | 154 | 11.8k | } |
|
155 | | |
156 | | METHODDEF(void) |
157 | | jpeg_undifference7(j_decompress_ptr cinfo, int comp_index, |
158 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
159 | | JDIFFROW undiff_buf, JDIMENSION width) |
160 | 227k | { |
161 | 227k | UNDIFFERENCE_2D(PREDICTOR7); |
162 | 227k | (void)(Rc); |
163 | 227k | } jdlossls-8.c:jpeg_undifference7 Line | Count | Source | 160 | 44.4k | { | 161 | 44.4k | UNDIFFERENCE_2D(PREDICTOR7); | 162 | 44.4k | (void)(Rc); | 163 | 44.4k | } |
jdlossls-12.c:jpeg_undifference7 Line | Count | Source | 160 | 1.72k | { | 161 | 1.72k | UNDIFFERENCE_2D(PREDICTOR7); | 162 | 1.72k | (void)(Rc); | 163 | 1.72k | } |
jdlossls-16.c:jpeg_undifference7 Line | Count | Source | 160 | 181k | { | 161 | 181k | UNDIFFERENCE_2D(PREDICTOR7); | 162 | 181k | (void)(Rc); | 163 | 181k | } |
|
164 | | |
165 | | |
166 | | /* |
167 | | * Undifferencer for the first row in a scan or restart interval. The first |
168 | | * sample in the row is undifferenced using the special predictor constant |
169 | | * x=2^(P-Pt-1). The rest of the samples are undifferenced using the |
170 | | * 1-D horizontal predictor (1). |
171 | | */ |
172 | | |
173 | | METHODDEF(void) |
174 | | jpeg_undifference_first_row(j_decompress_ptr cinfo, int comp_index, |
175 | | JDIFFROW diff_buf, JDIFFROW prev_row, |
176 | | JDIFFROW undiff_buf, JDIMENSION width) |
177 | 3.41M | { |
178 | 3.41M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
179 | | |
180 | 3.41M | UNDIFFERENCE_1D(INITIAL_PREDICTORx); |
181 | | |
182 | | /* |
183 | | * Now that we have undifferenced the first row, we want to use the |
184 | | * undifferencer that corresponds to the predictor specified in the |
185 | | * scan header. |
186 | | */ |
187 | 3.41M | switch (cinfo->Ss) { |
188 | 1.34M | case 1: |
189 | 1.34M | losslessd->predict_undifference[comp_index] = jpeg_undifference1; |
190 | 1.34M | break; |
191 | 229k | case 2: |
192 | 229k | losslessd->predict_undifference[comp_index] = jpeg_undifference2; |
193 | 229k | break; |
194 | 1.01M | case 3: |
195 | 1.01M | losslessd->predict_undifference[comp_index] = jpeg_undifference3; |
196 | 1.01M | break; |
197 | 355k | case 4: |
198 | 355k | losslessd->predict_undifference[comp_index] = jpeg_undifference4; |
199 | 355k | break; |
200 | 242k | case 5: |
201 | 242k | losslessd->predict_undifference[comp_index] = jpeg_undifference5; |
202 | 242k | break; |
203 | 57.4k | case 6: |
204 | 57.4k | losslessd->predict_undifference[comp_index] = jpeg_undifference6; |
205 | 57.4k | break; |
206 | 173k | case 7: |
207 | 173k | losslessd->predict_undifference[comp_index] = jpeg_undifference7; |
208 | 173k | break; |
209 | 0 | default: |
210 | 0 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, |
211 | 3.41M | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); |
212 | 3.41M | } |
213 | 3.41M | } jdlossls-8.c:jpeg_undifference_first_row Line | Count | Source | 177 | 1.99M | { | 178 | 1.99M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 179 | | | 180 | 1.99M | UNDIFFERENCE_1D(INITIAL_PREDICTORx); | 181 | | | 182 | | /* | 183 | | * Now that we have undifferenced the first row, we want to use the | 184 | | * undifferencer that corresponds to the predictor specified in the | 185 | | * scan header. | 186 | | */ | 187 | 1.99M | switch (cinfo->Ss) { | 188 | 986k | case 1: | 189 | 986k | losslessd->predict_undifference[comp_index] = jpeg_undifference1; | 190 | 986k | break; | 191 | 14.8k | case 2: | 192 | 14.8k | losslessd->predict_undifference[comp_index] = jpeg_undifference2; | 193 | 14.8k | break; | 194 | 798k | case 3: | 195 | 798k | losslessd->predict_undifference[comp_index] = jpeg_undifference3; | 196 | 798k | break; | 197 | 142k | case 4: | 198 | 142k | losslessd->predict_undifference[comp_index] = jpeg_undifference4; | 199 | 142k | break; | 200 | 5.90k | case 5: | 201 | 5.90k | losslessd->predict_undifference[comp_index] = jpeg_undifference5; | 202 | 5.90k | break; | 203 | 1.15k | case 6: | 204 | 1.15k | losslessd->predict_undifference[comp_index] = jpeg_undifference6; | 205 | 1.15k | break; | 206 | 40.3k | case 7: | 207 | 40.3k | losslessd->predict_undifference[comp_index] = jpeg_undifference7; | 208 | 40.3k | break; | 209 | 0 | default: | 210 | 0 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, | 211 | 1.99M | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); | 212 | 1.99M | } | 213 | 1.99M | } |
jdlossls-12.c:jpeg_undifference_first_row Line | Count | Source | 177 | 707k | { | 178 | 707k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 179 | | | 180 | 707k | UNDIFFERENCE_1D(INITIAL_PREDICTORx); | 181 | | | 182 | | /* | 183 | | * Now that we have undifferenced the first row, we want to use the | 184 | | * undifferencer that corresponds to the predictor specified in the | 185 | | * scan header. | 186 | | */ | 187 | 707k | switch (cinfo->Ss) { | 188 | 94.7k | case 1: | 189 | 94.7k | losslessd->predict_undifference[comp_index] = jpeg_undifference1; | 190 | 94.7k | break; | 191 | 156k | case 2: | 192 | 156k | losslessd->predict_undifference[comp_index] = jpeg_undifference2; | 193 | 156k | break; | 194 | 164k | case 3: | 195 | 164k | losslessd->predict_undifference[comp_index] = jpeg_undifference3; | 196 | 164k | break; | 197 | 91.4k | case 4: | 198 | 91.4k | losslessd->predict_undifference[comp_index] = jpeg_undifference4; | 199 | 91.4k | break; | 200 | 145k | case 5: | 201 | 145k | losslessd->predict_undifference[comp_index] = jpeg_undifference5; | 202 | 145k | break; | 203 | 51.6k | case 6: | 204 | 51.6k | losslessd->predict_undifference[comp_index] = jpeg_undifference6; | 205 | 51.6k | break; | 206 | 3.62k | case 7: | 207 | 3.62k | losslessd->predict_undifference[comp_index] = jpeg_undifference7; | 208 | 3.62k | break; | 209 | 0 | default: | 210 | 0 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, | 211 | 707k | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); | 212 | 707k | } | 213 | 707k | } |
jdlossls-16.c:jpeg_undifference_first_row Line | Count | Source | 177 | 721k | { | 178 | 721k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 179 | | | 180 | 721k | UNDIFFERENCE_1D(INITIAL_PREDICTORx); | 181 | | | 182 | | /* | 183 | | * Now that we have undifferenced the first row, we want to use the | 184 | | * undifferencer that corresponds to the predictor specified in the | 185 | | * scan header. | 186 | | */ | 187 | 721k | switch (cinfo->Ss) { | 188 | 263k | case 1: | 189 | 263k | losslessd->predict_undifference[comp_index] = jpeg_undifference1; | 190 | 263k | break; | 191 | 58.2k | case 2: | 192 | 58.2k | losslessd->predict_undifference[comp_index] = jpeg_undifference2; | 193 | 58.2k | break; | 194 | 52.3k | case 3: | 195 | 52.3k | losslessd->predict_undifference[comp_index] = jpeg_undifference3; | 196 | 52.3k | break; | 197 | 121k | case 4: | 198 | 121k | losslessd->predict_undifference[comp_index] = jpeg_undifference4; | 199 | 121k | break; | 200 | 91.5k | case 5: | 201 | 91.5k | losslessd->predict_undifference[comp_index] = jpeg_undifference5; | 202 | 91.5k | break; | 203 | 4.61k | case 6: | 204 | 4.61k | losslessd->predict_undifference[comp_index] = jpeg_undifference6; | 205 | 4.61k | break; | 206 | 129k | case 7: | 207 | 129k | losslessd->predict_undifference[comp_index] = jpeg_undifference7; | 208 | 129k | break; | 209 | 0 | default: | 210 | 0 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, | 211 | 721k | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); | 212 | 721k | } | 213 | 721k | } |
|
214 | | |
215 | | |
216 | | /*********************** Sample upscaling by 2^Pt ************************/ |
217 | | |
218 | | METHODDEF(void) |
219 | | simple_upscale(j_decompress_ptr cinfo, |
220 | | JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width) |
221 | 3.66M | { |
222 | 21.8M | do { |
223 | 21.8M | *output_buf++ = (_JSAMPLE)(*diff_buf++ << cinfo->Al); |
224 | 21.8M | } while (--width); |
225 | 3.66M | } jdlossls-8.c:simple_upscale Line | Count | Source | 221 | 2.11M | { | 222 | 15.7M | do { | 223 | 15.7M | *output_buf++ = (_JSAMPLE)(*diff_buf++ << cinfo->Al); | 224 | 15.7M | } while (--width); | 225 | 2.11M | } |
jdlossls-12.c:simple_upscale Line | Count | Source | 221 | 1.03M | { | 222 | 2.79M | do { | 223 | 2.79M | *output_buf++ = (_JSAMPLE)(*diff_buf++ << cinfo->Al); | 224 | 2.79M | } while (--width); | 225 | 1.03M | } |
jdlossls-16.c:simple_upscale Line | Count | Source | 221 | 522k | { | 222 | 3.26M | do { | 223 | 3.26M | *output_buf++ = (_JSAMPLE)(*diff_buf++ << cinfo->Al); | 224 | 3.26M | } while (--width); | 225 | 522k | } |
|
226 | | |
227 | | METHODDEF(void) |
228 | | noscale(j_decompress_ptr cinfo, |
229 | | JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width) |
230 | 3.54M | { |
231 | 24.5M | do { |
232 | 24.5M | *output_buf++ = (_JSAMPLE)(*diff_buf++); |
233 | 24.5M | } while (--width); |
234 | 3.54M | } Line | Count | Source | 230 | 2.29M | { | 231 | 16.9M | do { | 232 | 16.9M | *output_buf++ = (_JSAMPLE)(*diff_buf++); | 233 | 16.9M | } while (--width); | 234 | 2.29M | } |
Line | Count | Source | 230 | 337k | { | 231 | 4.26M | do { | 232 | 4.26M | *output_buf++ = (_JSAMPLE)(*diff_buf++); | 233 | 4.26M | } while (--width); | 234 | 337k | } |
Line | Count | Source | 230 | 911k | { | 231 | 3.38M | do { | 232 | 3.38M | *output_buf++ = (_JSAMPLE)(*diff_buf++); | 233 | 3.38M | } while (--width); | 234 | 911k | } |
|
235 | | |
236 | | |
237 | | /* |
238 | | * Initialize for an input processing pass. |
239 | | */ |
240 | | |
241 | | METHODDEF(void) |
242 | | start_pass_lossless(j_decompress_ptr cinfo) |
243 | 5.81M | { |
244 | 5.81M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
245 | 5.81M | int ci; |
246 | | |
247 | | /* Check that the scan parameters Ss, Se, Ah, Al are OK for lossless JPEG. |
248 | | * |
249 | | * Ss is the predictor selection value (psv). Legal values for sequential |
250 | | * lossless JPEG are: 1 <= psv <= 7. |
251 | | * |
252 | | * Se and Ah are not used and should be zero. |
253 | | * |
254 | | * Al specifies the point transform (Pt). |
255 | | * Legal values are: 0 <= Pt <= (data precision - 1). |
256 | | */ |
257 | 5.81M | if (cinfo->Ss < 1 || cinfo->Ss > 7 || |
258 | 5.81M | cinfo->Se != 0 || cinfo->Ah != 0 || |
259 | 5.81M | cinfo->Al < 0 || cinfo->Al >= cinfo->data_precision) |
260 | 65 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, |
261 | 5.81M | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); |
262 | | |
263 | | /* Set undifference functions to first row function */ |
264 | 17.5M | for (ci = 0; ci < cinfo->num_components; ci++) |
265 | 11.7M | losslessd->predict_undifference[ci] = jpeg_undifference_first_row; |
266 | | |
267 | | /* Set scaler function based on Pt */ |
268 | 5.81M | if (cinfo->Al) |
269 | 3.61M | losslessd->scaler_scale = simple_upscale; |
270 | 2.20M | else |
271 | 2.20M | losslessd->scaler_scale = noscale; |
272 | 5.81M | } jdlossls-8.c:start_pass_lossless Line | Count | Source | 243 | 3.03M | { | 244 | 3.03M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 245 | 3.03M | int ci; | 246 | | | 247 | | /* Check that the scan parameters Ss, Se, Ah, Al are OK for lossless JPEG. | 248 | | * | 249 | | * Ss is the predictor selection value (psv). Legal values for sequential | 250 | | * lossless JPEG are: 1 <= psv <= 7. | 251 | | * | 252 | | * Se and Ah are not used and should be zero. | 253 | | * | 254 | | * Al specifies the point transform (Pt). | 255 | | * Legal values are: 0 <= Pt <= (data precision - 1). | 256 | | */ | 257 | 3.03M | if (cinfo->Ss < 1 || cinfo->Ss > 7 || | 258 | 3.03M | cinfo->Se != 0 || cinfo->Ah != 0 || | 259 | 3.03M | cinfo->Al < 0 || cinfo->Al >= cinfo->data_precision) | 260 | 23 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, | 261 | 3.03M | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); | 262 | | | 263 | | /* Set undifference functions to first row function */ | 264 | 9.11M | for (ci = 0; ci < cinfo->num_components; ci++) | 265 | 6.07M | losslessd->predict_undifference[ci] = jpeg_undifference_first_row; | 266 | | | 267 | | /* Set scaler function based on Pt */ | 268 | 3.03M | if (cinfo->Al) | 269 | 2.01M | losslessd->scaler_scale = simple_upscale; | 270 | 1.02M | else | 271 | 1.02M | losslessd->scaler_scale = noscale; | 272 | 3.03M | } |
jdlossls-12.c:start_pass_lossless Line | Count | Source | 243 | 1.34M | { | 244 | 1.34M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 245 | 1.34M | int ci; | 246 | | | 247 | | /* Check that the scan parameters Ss, Se, Ah, Al are OK for lossless JPEG. | 248 | | * | 249 | | * Ss is the predictor selection value (psv). Legal values for sequential | 250 | | * lossless JPEG are: 1 <= psv <= 7. | 251 | | * | 252 | | * Se and Ah are not used and should be zero. | 253 | | * | 254 | | * Al specifies the point transform (Pt). | 255 | | * Legal values are: 0 <= Pt <= (data precision - 1). | 256 | | */ | 257 | 1.34M | if (cinfo->Ss < 1 || cinfo->Ss > 7 || | 258 | 1.34M | cinfo->Se != 0 || cinfo->Ah != 0 || | 259 | 1.34M | cinfo->Al < 0 || cinfo->Al >= cinfo->data_precision) | 260 | 22 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, | 261 | 1.34M | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); | 262 | | | 263 | | /* Set undifference functions to first row function */ | 264 | 4.13M | for (ci = 0; ci < cinfo->num_components; ci++) | 265 | 2.79M | losslessd->predict_undifference[ci] = jpeg_undifference_first_row; | 266 | | | 267 | | /* Set scaler function based on Pt */ | 268 | 1.34M | if (cinfo->Al) | 269 | 1.06M | losslessd->scaler_scale = simple_upscale; | 270 | 271k | else | 271 | 271k | losslessd->scaler_scale = noscale; | 272 | 1.34M | } |
jdlossls-16.c:start_pass_lossless Line | Count | Source | 243 | 1.43M | { | 244 | 1.43M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 245 | 1.43M | int ci; | 246 | | | 247 | | /* Check that the scan parameters Ss, Se, Ah, Al are OK for lossless JPEG. | 248 | | * | 249 | | * Ss is the predictor selection value (psv). Legal values for sequential | 250 | | * lossless JPEG are: 1 <= psv <= 7. | 251 | | * | 252 | | * Se and Ah are not used and should be zero. | 253 | | * | 254 | | * Al specifies the point transform (Pt). | 255 | | * Legal values are: 0 <= Pt <= (data precision - 1). | 256 | | */ | 257 | 1.43M | if (cinfo->Ss < 1 || cinfo->Ss > 7 || | 258 | 1.43M | cinfo->Se != 0 || cinfo->Ah != 0 || | 259 | 1.43M | cinfo->Al < 0 || cinfo->Al >= cinfo->data_precision) | 260 | 20 | ERREXIT4(cinfo, JERR_BAD_PROGRESSION, | 261 | 1.43M | cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); | 262 | | | 263 | | /* Set undifference functions to first row function */ | 264 | 4.32M | for (ci = 0; ci < cinfo->num_components; ci++) | 265 | 2.88M | losslessd->predict_undifference[ci] = jpeg_undifference_first_row; | 266 | | | 267 | | /* Set scaler function based on Pt */ | 268 | 1.43M | if (cinfo->Al) | 269 | 524k | losslessd->scaler_scale = simple_upscale; | 270 | 913k | else | 271 | 913k | losslessd->scaler_scale = noscale; | 272 | 1.43M | } |
|
273 | | |
274 | | |
275 | | /* |
276 | | * Initialize the lossless decompressor. |
277 | | */ |
278 | | |
279 | | GLOBAL(void) |
280 | | _jinit_lossless_decompressor(j_decompress_ptr cinfo) |
281 | 1.02k | { |
282 | 1.02k | lossless_decomp_ptr losslessd; |
283 | | |
284 | | #if BITS_IN_JSAMPLE == 8 |
285 | 431 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
286 | | #else |
287 | 595 | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
288 | 595 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
289 | 0 | #endif |
290 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
291 | | |
292 | | /* Create subobject in permanent pool */ |
293 | 1.02k | losslessd = (lossless_decomp_ptr) |
294 | 1.02k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT, |
295 | 1.02k | sizeof(jpeg_lossless_decompressor)); |
296 | 1.02k | cinfo->idct = (struct jpeg_inverse_dct *)losslessd; |
297 | 1.02k | losslessd->pub.start_pass = start_pass_lossless; |
298 | 1.02k | } jinit_lossless_decompressor Line | Count | Source | 281 | 431 | { | 282 | 431 | lossless_decomp_ptr losslessd; | 283 | | | 284 | 431 | #if BITS_IN_JSAMPLE == 8 | 285 | 431 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 286 | | #else | 287 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 288 | | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 289 | | #endif | 290 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 291 | | | 292 | | /* Create subobject in permanent pool */ | 293 | 431 | losslessd = (lossless_decomp_ptr) | 294 | 431 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT, | 295 | 431 | sizeof(jpeg_lossless_decompressor)); | 296 | 431 | cinfo->idct = (struct jpeg_inverse_dct *)losslessd; | 297 | 431 | losslessd->pub.start_pass = start_pass_lossless; | 298 | 431 | } |
j12init_lossless_decompressor Line | Count | Source | 281 | 292 | { | 282 | 292 | lossless_decomp_ptr losslessd; | 283 | | | 284 | | #if BITS_IN_JSAMPLE == 8 | 285 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 286 | | #else | 287 | 292 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 288 | 292 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 289 | 0 | #endif | 290 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 291 | | | 292 | | /* Create subobject in permanent pool */ | 293 | 292 | losslessd = (lossless_decomp_ptr) | 294 | 292 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT, | 295 | 292 | sizeof(jpeg_lossless_decompressor)); | 296 | 292 | cinfo->idct = (struct jpeg_inverse_dct *)losslessd; | 297 | 292 | losslessd->pub.start_pass = start_pass_lossless; | 298 | 292 | } |
j16init_lossless_decompressor Line | Count | Source | 281 | 303 | { | 282 | 303 | lossless_decomp_ptr losslessd; | 283 | | | 284 | | #if BITS_IN_JSAMPLE == 8 | 285 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 286 | | #else | 287 | 303 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 288 | 303 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 289 | 0 | #endif | 290 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 291 | | | 292 | | /* Create subobject in permanent pool */ | 293 | 303 | losslessd = (lossless_decomp_ptr) | 294 | 303 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT, | 295 | 303 | sizeof(jpeg_lossless_decompressor)); | 296 | 303 | cinfo->idct = (struct jpeg_inverse_dct *)losslessd; | 297 | 303 | losslessd->pub.start_pass = start_pass_lossless; | 298 | 303 | } |
|
299 | | |
300 | | #endif /* D_LOSSLESS_SUPPORTED */ |