========================================================================= */
(strm, level, strategy)
| 569 | |
| 570 | /* ========================================================================= */ |
| 571 | int ZEXPORT deflateParams(strm, level, strategy) |
| 572 | z_streamp strm; |
| 573 | int level; |
| 574 | int strategy; |
| 575 | { |
| 576 | deflate_state *s; |
| 577 | compress_func func; |
| 578 | |
| 579 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 580 | s = strm->state; |
| 581 | |
| 582 | #ifdef FASTEST |
| 583 | if (level != 0) level = 1; |
| 584 | #else |
| 585 | if (level == Z_DEFAULT_COMPRESSION) level = 6; |
| 586 | #endif |
| 587 | if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { |
| 588 | return Z_STREAM_ERROR; |
| 589 | } |
| 590 | func = configuration_table[s->level].func; |
| 591 | |
| 592 | if ((strategy != s->strategy || func != configuration_table[level].func) && |
| 593 | s->last_flush != -2) { |
| 594 | /* Flush the last buffer: */ |
| 595 | int err = deflate(strm, Z_BLOCK); |
| 596 | if (err == Z_STREAM_ERROR) |
| 597 | return err; |
| 598 | if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) |
| 599 | return Z_BUF_ERROR; |
| 600 | } |
| 601 | if (s->level != level) { |
| 602 | if (s->level == 0 && s->matches != 0) { |
| 603 | if (s->matches == 1) |
| 604 | slide_hash(s); |
| 605 | else |
| 606 | CLEAR_HASH(s); |
| 607 | s->matches = 0; |
| 608 | } |
| 609 | s->level = level; |
| 610 | s->max_lazy_match = configuration_table[level].max_lazy; |
| 611 | s->good_match = configuration_table[level].good_length; |
| 612 | s->nice_match = configuration_table[level].nice_length; |
| 613 | s->max_chain_length = configuration_table[level].max_chain; |
| 614 | } |
| 615 | s->strategy = strategy; |
| 616 | return Z_OK; |
| 617 | } |
| 618 | |
| 619 | /* ========================================================================= */ |
| 620 | int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) |