OLD | NEW |
1 /* | 1 /* |
2 * jdhuff.h | 2 * jdhuff.h |
3 * | 3 * |
4 * Copyright (C) 1991-1997, Thomas G. Lane. | 4 * Copyright (C) 1991-1997, Thomas G. Lane. |
5 * Copyright (C) 2010, D. R. Commander. | 5 * Copyright (C) 2010-2011, D. R. Commander. |
6 * This file is part of the Independent JPEG Group's software. | 6 * This file is part of the Independent JPEG Group's software. |
7 * For conditions of distribution and use, see the accompanying README file. | 7 * For conditions of distribution and use, see the accompanying README file. |
8 * | 8 * |
9 * This file contains declarations for Huffman entropy decoding routines | 9 * This file contains declarations for Huffman entropy decoding routines |
10 * that are shared between the sequential decoder (jdhuff.c) and the | 10 * that are shared between the sequential decoder (jdhuff.c) and the |
11 * progressive decoder (jdphuff.c). No other modules need to see these. | 11 * progressive decoder (jdphuff.c). No other modules need to see these. |
12 */ | 12 */ |
13 | 13 |
14 /* Short forms of external names for systems with brain-damaged linkers. */ | 14 /* Short forms of external names for systems with brain-damaged linkers. */ |
15 | 15 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 DROP_BITS(nb); \ | 201 DROP_BITS(nb); \ |
202 result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \ | 202 result = htbl->lookup[look] & ((1 << HUFF_LOOKAHEAD) - 1); \ |
203 } else { \ | 203 } else { \ |
204 slowlabel: \ | 204 slowlabel: \ |
205 if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ | 205 if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ |
206 { failaction; } \ | 206 { failaction; } \ |
207 get_buffer = state.get_buffer; bits_left = state.bits_left; \ | 207 get_buffer = state.get_buffer; bits_left = state.bits_left; \ |
208 } \ | 208 } \ |
209 } | 209 } |
210 | 210 |
| 211 #define HUFF_DECODE_FAST(s,nb,htbl) \ |
| 212 FILL_BIT_BUFFER_FAST; \ |
| 213 s = PEEK_BITS(HUFF_LOOKAHEAD); \ |
| 214 s = htbl->lookup[s]; \ |
| 215 nb = s >> HUFF_LOOKAHEAD; \ |
| 216 /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \ |
| 217 DROP_BITS(nb); \ |
| 218 s = s & ((1 << HUFF_LOOKAHEAD) - 1); \ |
| 219 if (nb > HUFF_LOOKAHEAD) { \ |
| 220 /* Equivalent of jpeg_huff_decode() */ \ |
| 221 /* Don't use GET_BITS() here because we don't want to modify bits_left */ \ |
| 222 s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \ |
| 223 while (s > htbl->maxcode[nb]) { \ |
| 224 s <<= 1; \ |
| 225 s |= GET_BITS(1); \ |
| 226 nb++; \ |
| 227 } \ |
| 228 s = htbl->pub->huffval[ (int) (s + htbl->valoffset[nb]) & 0xFF ]; \ |
| 229 } |
| 230 |
211 /* Out-of-line case for Huffman code fetching */ | 231 /* Out-of-line case for Huffman code fetching */ |
212 EXTERN(int) jpeg_huff_decode | 232 EXTERN(int) jpeg_huff_decode |
213 JPP((bitread_working_state * state, register bit_buf_type get_buffer, | 233 JPP((bitread_working_state * state, register bit_buf_type get_buffer, |
214 register int bits_left, d_derived_tbl * htbl, int min_bits)); | 234 register int bits_left, d_derived_tbl * htbl, int min_bits)); |
OLD | NEW |