< prev index next >

## src/java.desktop/share/native/libjavajpeg/jdhuff.c

 ``` `````` 438 439 440 /* 441 * Figure F.12: extend sign bit. 442 * On some machines, a shift and add will be faster than a table lookup. 443 */ 444 445 #ifdef AVOID_TABLES 446 447 #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) 448 449 #else 450 451 #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) 452 453 static const int extend_test[16] = /* entry n is 2**(n-1) */ 454 { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 455 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; 456 457 static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ 458 { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, 459 ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, 460 ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, 461 ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; 462 463 #endif /* AVOID_TABLES */ 464 465 466 /* 467 * Check for a restart marker & resynchronize decoder. 468 * Returns FALSE if must suspend. 469 */ 470 471 LOCAL(boolean) 472 process_restart (j_decompress_ptr cinfo) 473 { 474 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; 475 int ci; 476 477 /* Throw away any unused bits remaining in bit buffer; */ 478 /* include any full bytes in next_marker's count of discarded bytes */ 479 cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; 480 entropy->bitstate.bits_left = 0; 481 ``` ``` `````` 438 439 440 /* 441 * Figure F.12: extend sign bit. 442 * On some machines, a shift and add will be faster than a table lookup. 443 */ 444 445 #ifdef AVOID_TABLES 446 447 #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) 448 449 #else 450 451 #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) 452 453 static const int extend_test[16] = /* entry n is 2**(n-1) */ 454 { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 455 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; 456 457 static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ 458 { 0, (0xffffffff<<1) + 1, (0xffffffff<<2) + 1, (0xffffffff<<3) + 1, (0xffffffff<<4) + 1, 459 (0xffffffff<<5) + 1, (0xffffffff<<6) + 1, (0xffffffff<<7) + 1, (0xffffffff<<8) + 1, 460 (0xffffffff<<9) + 1, (0xffffffff<<10) + 1, (0xffffffff<<11) + 1, (0xffffffff<<12) + 1, 461 (0xffffffff<<13) + 1, (0xffffffff<<14) + 1, (0xffffffff<<15) + 1 }; 462 463 #endif /* AVOID_TABLES */ 464 465 466 /* 467 * Check for a restart marker & resynchronize decoder. 468 * Returns FALSE if must suspend. 469 */ 470 471 LOCAL(boolean) 472 process_restart (j_decompress_ptr cinfo) 473 { 474 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; 475 int ci; 476 477 /* Throw away any unused bits remaining in bit buffer; */ 478 /* include any full bytes in next_marker's count of discarded bytes */ 479 cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; 480 entropy->bitstate.bits_left = 0; 481 ```