ZLIB
Loading...
Searching...
No Matches
inffast.c File Reference

Fast decoding. More...

#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"

Functions

void ZLIB_INTERNAL inflate_fast (z_streamp strm, unsigned start)
 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.
 

Detailed Description

Fast decoding.

Copyright (C) 1995-2017 Mark Adler For conditions of distribution and use, see copyright notice in zlib.h

Function Documentation

◆ inflate_fast()

void ZLIB_INTERNAL inflate_fast ( z_streamp  strm,
unsigned  start 
)

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 is spent in this routine.

Entry assumptions:

state->mode == LEN
strm->avail_in >= 6
strm->avail_out >= 258
start >= strm->avail_out
state->bits < 8
@ LEN
i: waiting for length/lit/eob code
Definition inflate.h:43

On return, state->mode is one of:

- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data

Notes:

  • The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, and 13 bits for the distance extra. This totals 48 bits, or six bytes. Therefore if strm->avail_in >= 6, then there is enough input to avoid checking for available input while decoding.
  • The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() requires strm->avail_out >= 258 for each loop to avoid checking for output space.