| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#define JPEG_INTERNALS |
| 18 |
#include "jinclude.h" |
| 19 |
#include "jpeglib.h" |
| 20 |
#include "jdhuff.h" |
| 21 |
|
| 22 |
|
| 23 |
#ifdef D_PROGRESSIVE_SUPPORTED |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
typedef struct { |
| 33 |
unsigned int EOBRUN; |
| 34 |
int last_dc_val[MAX_COMPS_IN_SCAN]; |
| 35 |
} savable_state; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
#ifndef NO_STRUCT_ASSIGN |
| 43 |
#define ASSIGN_STATE(dest,src) ((dest) = (src)) |
| 44 |
#else |
| 45 |
#if MAX_COMPS_IN_SCAN == 4 |
| 46 |
#define ASSIGN_STATE(dest,src) \ |
| 47 |
((dest).EOBRUN = (src).EOBRUN, \ |
| 48 |
(dest).last_dc_val[0] = (src).last_dc_val[0], \ |
| 49 |
(dest).last_dc_val[1] = (src).last_dc_val[1], \ |
| 50 |
(dest).last_dc_val[2] = (src).last_dc_val[2], \ |
| 51 |
(dest).last_dc_val[3] = (src).last_dc_val[3]) |
| 52 |
#endif |
| 53 |
#endif |
| 54 |
|
| 55 |
|
| 56 |
typedef struct { |
| 57 |
struct jpeg_entropy_decoder pub; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
bitread_perm_state bitstate; |
| 63 |
savable_state saved; |
| 64 |
|
| 65 |
|
| 66 |
unsigned int restarts_to_go; |
| 67 |
|
| 68 |
|
| 69 |
d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; |
| 70 |
|
| 71 |
d_derived_tbl * ac_derived_tbl; |
| 72 |
} phuff_entropy_decoder; |
| 73 |
|
| 74 |
typedef phuff_entropy_decoder * phuff_entropy_ptr; |
| 75 |
|
| 76 |
|
| 77 |
METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, |
| 78 |
JBLOCKROW *MCU_data)); |
| 79 |
METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, |
| 80 |
JBLOCKROW *MCU_data)); |
| 81 |
METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, |
| 82 |
JBLOCKROW *MCU_data)); |
| 83 |
METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, |
| 84 |
JBLOCKROW *MCU_data)); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
METHODDEF(void) |
| 92 |
start_pass_phuff_decoder (j_decompress_ptr cinfo) |
| 93 |
{ |
| 94 |
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; |
| 95 |
boolean is_DC_band, bad; |
| 96 |
int ci, coefi, tbl; |
| 97 |
int *coef_bit_ptr; |
| 98 |
jpeg_component_info * compptr; |
| 99 |
|
| 100 |
is_DC_band = (cinfo->Ss == 0); |
| 101 |
|
| 102 |
|
| 103 |
bad = FALSE; |
| 104 |
if (is_DC_band) { |
| 105 |
if (cinfo->Se != 0) |
| 106 |
bad = TRUE; |
| 107 |
} else { |
| 108 |
|
| 109 |
if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) |
| 110 |
bad = TRUE; |
| 111 |
|
| 112 |
if (cinfo->comps_in_scan != 1) |
| 113 |
bad = TRUE; |
| 114 |
} |
| 115 |
if (cinfo->Ah != 0) { |
| 116 |
|
| 117 |
if (cinfo->Al != cinfo->Ah-1) |
| 118 |
bad = TRUE; |
| 119 |
} |
| 120 |
if (cinfo->Al > 13) |
| 121 |
bad = TRUE; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
if (bad) |
| 129 |
ERREXIT4(cinfo, JERR_BAD_PROGRESSION, |
| 130 |
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
| 136 |
int cindex = cinfo->cur_comp_info[ci]->component_index; |
| 137 |
coef_bit_ptr = & cinfo->coef_bits[cindex][0]; |
| 138 |
if (!is_DC_band && coef_bit_ptr[0] < 0) |
| 139 |
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); |
| 140 |
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { |
| 141 |
int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; |
| 142 |
if (cinfo->Ah != expected) |
| 143 |
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); |
| 144 |
coef_bit_ptr[coefi] = cinfo->Al; |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
if (cinfo->Ah == 0) { |
| 150 |
if (is_DC_band) |
| 151 |
entropy->pub.decode_mcu = decode_mcu_DC_first; |
| 152 |
else |
| 153 |
entropy->pub.decode_mcu = decode_mcu_AC_first; |
| 154 |
} else { |
| 155 |
if (is_DC_band) |
| 156 |
entropy->pub.decode_mcu = decode_mcu_DC_refine; |
| 157 |
else |
| 158 |
entropy->pub.decode_mcu = decode_mcu_AC_refine; |
| 159 |
} |
| 160 |
|
| 161 |
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
| 162 |
compptr = cinfo->cur_comp_info[ci]; |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
if (is_DC_band) { |
| 167 |
if (cinfo->Ah == 0) { |
| 168 |
tbl = compptr->dc_tbl_no; |
| 169 |
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, |
| 170 |
& entropy->derived_tbls[tbl]); |
| 171 |
} |
| 172 |
} else { |
| 173 |
tbl = compptr->ac_tbl_no; |
| 174 |
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, |
| 175 |
& entropy->derived_tbls[tbl]); |
| 176 |
|
| 177 |
entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; |
| 178 |
} |
| 179 |
|
| 180 |
entropy->saved.last_dc_val[ci] = 0; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
entropy->bitstate.bits_left = 0; |
| 185 |
entropy->bitstate.get_buffer = 0; |
| 186 |
entropy->pub.insufficient_data = FALSE; |
| 187 |
|
| 188 |
|
| 189 |
entropy->saved.EOBRUN = 0; |
| 190 |
|
| 191 |
|
| 192 |
entropy->restarts_to_go = cinfo->restart_interval; |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
#ifdef AVOID_TABLES |
| 202 |
|
| 203 |
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) |
| 204 |
|
| 205 |
#else |
| 206 |
|
| 207 |
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) |
| 208 |
|
| 209 |
static const int extend_test[16] = |
| 210 |
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, |
| 211 |
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; |
| 212 |
|
| 213 |
static const int extend_offset[16] = |
| 214 |
{ 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, |
| 215 |
((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, |
| 216 |
((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, |
| 217 |
((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; |
| 218 |
|
| 219 |
#endif |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
LOCAL(boolean) |
| 228 |
process_restart (j_decompress_ptr cinfo) |
| 229 |
{ |
| 230 |
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; |
| 231 |
int ci; |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; |
| 236 |
entropy->bitstate.bits_left = 0; |
| 237 |
|
| 238 |
|
| 239 |
if (! (*cinfo->marker->read_restart_marker) (cinfo)) |
| 240 |
return FALSE; |
| 241 |
|
| 242 |
|
| 243 |
for (ci = 0; ci < cinfo->comps_in_scan; ci++) |
| 244 |
entropy->saved.last_dc_val[ci] = 0; |
| 245 |
|
| 246 |
entropy->saved.EOBRUN = 0; |
| 247 |
|
| 248 |
|
| 249 |
entropy->restarts_to_go = cinfo->restart_interval; |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
if (cinfo->unread_marker == 0) |
| 257 |
entropy->pub.insufficient_data = FALSE; |
| 258 |
|
| 259 |
return TRUE; |
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
METHODDEF(boolean) |
| 286 |
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 287 |
{ |
| 288 |
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; |
| 289 |
int Al = cinfo->Al; |
| 290 |
register int s, r; |
| 291 |
int blkn, ci; |
| 292 |
JBLOCKROW block; |
| 293 |
BITREAD_STATE_VARS; |
| 294 |
savable_state state; |
| 295 |
d_derived_tbl * tbl; |
| 296 |
jpeg_component_info * compptr; |
| 297 |
|
| 298 |
|
| 299 |
if (cinfo->restart_interval) { |
| 300 |
if (entropy->restarts_to_go == 0) |
| 301 |
if (! process_restart(cinfo)) |
| 302 |
return FALSE; |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
if (! entropy->pub.insufficient_data) { |
| 309 |
|
| 310 |
|
| 311 |
BITREAD_LOAD_STATE(cinfo,entropy->bitstate); |
| 312 |
ASSIGN_STATE(state, entropy->saved); |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { |
| 317 |
block = MCU_data[blkn]; |
| 318 |
ci = cinfo->MCU_membership[blkn]; |
| 319 |
compptr = cinfo->cur_comp_info[ci]; |
| 320 |
tbl = entropy->derived_tbls[compptr->dc_tbl_no]; |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
HUFF_DECODE(s, br_state, tbl, return FALSE, label1); |
| 326 |
if (s) { |
| 327 |
CHECK_BIT_BUFFER(br_state, s, return FALSE); |
| 328 |
r = GET_BITS(s); |
| 329 |
s = HUFF_EXTEND(r, s); |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
s += state.last_dc_val[ci]; |
| 334 |
state.last_dc_val[ci] = s; |
| 335 |
|
| 336 |
(*block)[0] = (JCOEF) (s << Al); |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
BITREAD_SAVE_STATE(cinfo,entropy->bitstate); |
| 341 |
ASSIGN_STATE(entropy->saved, state); |
| 342 |
} |
| 343 |
|
| 344 |
|
| 345 |
entropy->restarts_to_go--; |
| 346 |
|
| 347 |
return TRUE; |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
METHODDEF(boolean) |
| 357 |
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 358 |
{ |
| 359 |
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; |
| 360 |
int Se = cinfo->Se; |
| 361 |
int Al = cinfo->Al; |
| 362 |
register int s, k, r; |
| 363 |
unsigned int EOBRUN; |
| 364 |
JBLOCKROW block; |
| 365 |
BITREAD_STATE_VARS; |
| 366 |
d_derived_tbl * tbl; |
| 367 |
|
| 368 |
|
| 369 |
if (cinfo->restart_interval) { |
| 370 |
if (entropy->restarts_to_go == 0) |
| 371 |
if (! process_restart(cinfo)) |
| 372 |
return FALSE; |
| 373 |
} |
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
if (! entropy->pub.insufficient_data) { |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
EOBRUN = entropy->saved.EOBRUN; |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
if (EOBRUN > 0) |
| 388 |
EOBRUN--; |
| 389 |
else { |
| 390 |
BITREAD_LOAD_STATE(cinfo,entropy->bitstate); |
| 391 |
block = MCU_data[0]; |
| 392 |
tbl = entropy->ac_derived_tbl; |
| 393 |
|
| 394 |
for (k = cinfo->Ss; k <= Se; k++) { |
| 395 |
HUFF_DECODE(s, br_state, tbl, return FALSE, label2); |
| 396 |
r = s >> 4; |
| 397 |
s &= 15; |
| 398 |
if (s) { |
| 399 |
k += r; |
| 400 |
CHECK_BIT_BUFFER(br_state, s, return FALSE); |
| 401 |
r = GET_BITS(s); |
| 402 |
s = HUFF_EXTEND(r, s); |
| 403 |
|
| 404 |
(*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); |
| 405 |
} else { |
| 406 |
if (r == 15) { |
| 407 |
k += 15; |
| 408 |
} else { |
| 409 |
EOBRUN = 1 << r; |
| 410 |
if (r) { |
| 411 |
CHECK_BIT_BUFFER(br_state, r, return FALSE); |
| 412 |
r = GET_BITS(r); |
| 413 |
EOBRUN += r; |
| 414 |
} |
| 415 |
EOBRUN--; |
| 416 |
break; |
| 417 |
} |
| 418 |
} |
| 419 |
} |
| 420 |
|
| 421 |
BITREAD_SAVE_STATE(cinfo,entropy->bitstate); |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
entropy->saved.EOBRUN = EOBRUN; |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
entropy->restarts_to_go--; |
| 430 |
|
| 431 |
return TRUE; |
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
METHODDEF(boolean) |
| 442 |
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 443 |
{ |
| 444 |
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; |
| 445 |
int p1 = 1 << cinfo->Al; |
| 446 |
int blkn; |
| 447 |
JBLOCKROW block; |
| 448 |
BITREAD_STATE_VARS; |
| 449 |
|
| 450 |
|
| 451 |
if (cinfo->restart_interval) { |
| 452 |
if (entropy->restarts_to_go == 0) |
| 453 |
if (! process_restart(cinfo)) |
| 454 |
return FALSE; |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
BITREAD_LOAD_STATE(cinfo,entropy->bitstate); |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { |
| 467 |
block = MCU_data[blkn]; |
| 468 |
|
| 469 |
|
| 470 |
CHECK_BIT_BUFFER(br_state, 1, return FALSE); |
| 471 |
if (GET_BITS(1)) |
| 472 |
(*block)[0] |= p1; |
| 473 |
|
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
BITREAD_SAVE_STATE(cinfo,entropy->bitstate); |
| 478 |
|
| 479 |
|
| 480 |
entropy->restarts_to_go--; |
| 481 |
|
| 482 |
return TRUE; |
| 483 |
} |
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
METHODDEF(boolean) |
| 491 |
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 492 |
{ |
| 493 |
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; |
| 494 |
int Se = cinfo->Se; |
| 495 |
int p1 = 1 << cinfo->Al; |
| 496 |
int m1 = (-1) << cinfo->Al; |
| 497 |
register int s, k, r; |
| 498 |
unsigned int EOBRUN; |
| 499 |
JBLOCKROW block; |
| 500 |
JCOEFPTR thiscoef; |
| 501 |
BITREAD_STATE_VARS; |
| 502 |
d_derived_tbl * tbl; |
| 503 |
int num_newnz; |
| 504 |
int newnz_pos[DCTSIZE2]; |
| 505 |
|
| 506 |
|
| 507 |
if (cinfo->restart_interval) { |
| 508 |
if (entropy->restarts_to_go == 0) |
| 509 |
if (! process_restart(cinfo)) |
| 510 |
return FALSE; |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
if (! entropy->pub.insufficient_data) { |
| 516 |
|
| 517 |
|
| 518 |
BITREAD_LOAD_STATE(cinfo,entropy->bitstate); |
| 519 |
EOBRUN = entropy->saved.EOBRUN; |
| 520 |
|
| 521 |
|
| 522 |
block = MCU_data[0]; |
| 523 |
tbl = entropy->ac_derived_tbl; |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
num_newnz = 0; |
| 532 |
|
| 533 |
|
| 534 |
k = cinfo->Ss; |
| 535 |
|
| 536 |
if (EOBRUN == 0) { |
| 537 |
for (; k <= Se; k++) { |
| 538 |
HUFF_DECODE(s, br_state, tbl, goto undoit, label3); |
| 539 |
r = s >> 4; |
| 540 |
s &= 15; |
| 541 |
if (s) { |
| 542 |
if (s != 1) |
| 543 |
WARNMS(cinfo, JWRN_HUFF_BAD_CODE); |
| 544 |
CHECK_BIT_BUFFER(br_state, 1, goto undoit); |
| 545 |
if (GET_BITS(1)) |
| 546 |
s = p1; |
| 547 |
else |
| 548 |
s = m1; |
| 549 |
} else { |
| 550 |
if (r != 15) { |
| 551 |
EOBRUN = 1 << r; |
| 552 |
if (r) { |
| 553 |
CHECK_BIT_BUFFER(br_state, r, goto undoit); |
| 554 |
r = GET_BITS(r); |
| 555 |
EOBRUN += r; |
| 556 |
} |
| 557 |
break; |
| 558 |
} |
| 559 |
|
| 560 |
} |
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
do { |
| 566 |
thiscoef = *block + jpeg_natural_order[k]; |
| 567 |
if (*thiscoef != 0) { |
| 568 |
CHECK_BIT_BUFFER(br_state, 1, goto undoit); |
| 569 |
if (GET_BITS(1)) { |
| 570 |
if ((*thiscoef & p1) == 0) { |
| 571 |
if (*thiscoef >= 0) |
| 572 |
*thiscoef += p1; |
| 573 |
else |
| 574 |
*thiscoef += m1; |
| 575 |
} |
| 576 |
} |
| 577 |
} else { |
| 578 |
if (--r < 0) |
| 579 |
break; |
| 580 |
} |
| 581 |
k++; |
| 582 |
} while (k <= Se); |
| 583 |
if (s) { |
| 584 |
int pos = jpeg_natural_order[k]; |
| 585 |
|
| 586 |
(*block)[pos] = (JCOEF) s; |
| 587 |
|
| 588 |
newnz_pos[num_newnz++] = pos; |
| 589 |
} |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
if (EOBRUN > 0) { |
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
for (; k <= Se; k++) { |
| 600 |
thiscoef = *block + jpeg_natural_order[k]; |
| 601 |
if (*thiscoef != 0) { |
| 602 |
CHECK_BIT_BUFFER(br_state, 1, goto undoit); |
| 603 |
if (GET_BITS(1)) { |
| 604 |
if ((*thiscoef & p1) == 0) { |
| 605 |
if (*thiscoef >= 0) |
| 606 |
*thiscoef += p1; |
| 607 |
else |
| 608 |
*thiscoef += m1; |
| 609 |
} |
| 610 |
} |
| 611 |
} |
| 612 |
} |
| 613 |
|
| 614 |
EOBRUN--; |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
BITREAD_SAVE_STATE(cinfo,entropy->bitstate); |
| 619 |
entropy->saved.EOBRUN = EOBRUN; |
| 620 |
} |
| 621 |
|
| 622 |
|
| 623 |
entropy->restarts_to_go--; |
| 624 |
|
| 625 |
return TRUE; |
| 626 |
|
| 627 |
undoit: |
| 628 |
|
| 629 |
while (num_newnz > 0) |
| 630 |
(*block)[newnz_pos[--num_newnz]] = 0; |
| 631 |
|
| 632 |
return FALSE; |
| 633 |
} |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
GLOBAL(void) |
| 641 |
jinit_phuff_decoder (j_decompress_ptr cinfo) |
| 642 |
{ |
| 643 |
phuff_entropy_ptr entropy; |
| 644 |
int *coef_bit_ptr; |
| 645 |
int ci, i; |
| 646 |
|
| 647 |
entropy = (phuff_entropy_ptr) |
| 648 |
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 649 |
SIZEOF(phuff_entropy_decoder)); |
| 650 |
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; |
| 651 |
entropy->pub.start_pass = start_pass_phuff_decoder; |
| 652 |
|
| 653 |
|
| 654 |
for (i = 0; i < NUM_HUFF_TBLS; i++) { |
| 655 |
entropy->derived_tbls[i] = NULL; |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
cinfo->coef_bits = (int (*)[DCTSIZE2]) |
| 660 |
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 661 |
cinfo->num_components*DCTSIZE2*SIZEOF(int)); |
| 662 |
coef_bit_ptr = & cinfo->coef_bits[0][0]; |
| 663 |
for (ci = 0; ci < cinfo->num_components; ci++) |
| 664 |
for (i = 0; i < DCTSIZE2; i++) |
| 665 |
*coef_bit_ptr++ = -1; |
| 666 |
} |
| 667 |
|
| 668 |
#endif |