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

Function inflate_fast

extern/zlib/src/inffast.c:50–304  ·  view source on GitHub ↗

Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is available, an end-of-block is encountered, or a data error is encountered. When large enough input and output buffers are supplied to inflate(), for example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time i

Source from the content-addressed store, hash-verified

48 output space.
49 */
50void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
51 struct inflate_state FAR *state;
52 z_const unsigned char FAR *in; /* local strm->next_in */
53 z_const unsigned char FAR *last; /* have enough input while in < last */
54 unsigned char FAR *out; /* local strm->next_out */
55 unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
56 unsigned char FAR *end; /* while out < end, enough space available */
57#ifdef INFLATE_STRICT
58 unsigned dmax; /* maximum distance from zlib header */
59#endif
60 unsigned wsize; /* window size or zero if not using window */
61 unsigned whave; /* valid bytes in the window */
62 unsigned wnext; /* window write index */
63 unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
64 unsigned long hold; /* local strm->hold */
65 unsigned bits; /* local strm->bits */
66 code const FAR *lcode; /* local strm->lencode */
67 code const FAR *dcode; /* local strm->distcode */
68 unsigned lmask; /* mask for first level of length codes */
69 unsigned dmask; /* mask for first level of distance codes */
70 code const *here; /* retrieved table entry */
71 unsigned op; /* code bits, operation, extra bits, or */
72 /* window position, window bytes to copy */
73 unsigned len; /* match length, unused bytes */
74 unsigned dist; /* match distance */
75 unsigned char FAR *from; /* where to copy match from */
76
77 /* copy state to local variables */
78 state = (struct inflate_state FAR *)strm->state;
79 in = strm->next_in;
80 last = in + (strm->avail_in - 5);
81 out = strm->next_out;
82 beg = out - (start - strm->avail_out);
83 end = out + (strm->avail_out - 257);
84#ifdef INFLATE_STRICT
85 dmax = state->dmax;
86#endif
87 wsize = state->wsize;
88 whave = state->whave;
89 wnext = state->wnext;
90 window = state->window;
91 hold = state->hold;
92 bits = state->bits;
93 lcode = state->lencode;
94 dcode = state->distcode;
95 lmask = (1U << state->lenbits) - 1;
96 dmask = (1U << state->distbits) - 1;
97
98 /* decode literals and length/distances until end-of-block or not enough
99 input data or output space */
100 do {
101 if (bits < 15) {
102 hold += (unsigned long)(*in++) << bits;
103 bits += 8;
104 hold += (unsigned long)(*in++) << bits;
105 bits += 8;
106 }
107 here = lcode + (hold & lmask);

Callers 2

inflateBackFunction · 0.85
inflate.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected