MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / deflateParams

Function deflateParams

extern/zlib/src/deflate.c:752–794  ·  view source on GitHub ↗

========================================================================= */

Source from the content-addressed store, hash-verified

750
751/* ========================================================================= */
752int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) {
753 deflate_state *s;
754 compress_func func;
755
756 if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
757 s = strm->state;
758
759#ifdef FASTEST
760 if (level != 0) level = 1;
761#else
762 if (level == Z_DEFAULT_COMPRESSION) level = 6;
763#endif
764 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
765 return Z_STREAM_ERROR;
766 }
767 func = configuration_table[s->level].func;
768
769 if ((strategy != s->strategy || func != configuration_table[level].func) &&
770 s->last_flush != -2) {
771 /* Flush the last buffer: */
772 int err = deflate(strm, Z_BLOCK);
773 if (err == Z_STREAM_ERROR)
774 return err;
775 if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
776 return Z_BUF_ERROR;
777 }
778 if (s->level != level) {
779 if (s->level == 0 && s->matches != 0) {
780 if (s->matches == 1)
781 slide_hash(s);
782 else
783 CLEAR_HASH(s);
784 s->matches = 0;
785 }
786 s->level = level;
787 s->max_lazy_match = configuration_table[level].max_lazy;
788 s->good_match = configuration_table[level].good_length;
789 s->nice_match = configuration_table[level].nice_length;
790 s->max_chain_length = configuration_table[level].max_chain;
791 }
792 s->strategy = strategy;
793 return Z_OK;
794}
795
796/* ========================================================================= */
797int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,

Callers 1

gzsetparamsFunction · 0.85

Calls 3

deflateStateCheckFunction · 0.85
deflateFunction · 0.85
slide_hashFunction · 0.85

Tested by

no test coverage detected