⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezzlib.pas

📁 很管用的GIS控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        begin
          if (m >= 258) and (n >= 10) then begin
            s.bitb := b;
            s.bitk := k;
            z.avail_in := n;
            Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
            z.next_in := p;
            s.write := q;
            r := inflate_fast(c^.lbits, c^.dbits, c^.ltree, c^.dtree, s, z);
            p := z.next_in;
            n := z.avail_in;
            b := s.bitb;
            k := s.bitk;
            q := s.write;
            if ptr2int(q) < ptr2int(s.read) then
              m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
            else
              m := uInt(ptr2int(s.zend) - ptr2int(q));
            if (r <> Z_OK) then begin
              if (r = Z_STREAM_END) then
                c^.mode := WASH
              else
                c^.mode := BADCODE;
              continue;
            end;
          end;
          c^.sub.code.need := c^.lbits;
          c^.sub.code.tree := c^.ltree;
          c^.mode := LEN; 
        end;
      LEN:
        begin
          j := c^.sub.code.need;
          while (k < j) do begin
            if (n <> 0) then
              r := Z_OK
            else begin
              s.bitb := b;
              s.bitk := k;
              z.avail_in := n;
              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
              z.next_in := p;
              s.write := q;
              inflate_codes := inflate_flush(s, z, r);
              exit;
            end;
            Dec(n);
            b := b or (uLong(p^) shl k);
            Inc(p);
            Inc(k, 8);
          end;
          t := c^.sub.code.tree;
          Inc(t, uInt(b) and inflate_mask[j]);
          b := b shr t^.bits;
          Dec(k, t^.bits);
          e := uInt(t^.exop);
          if (e = 0) then begin
            c^.sub.lit := t^.base;
            c^.mode := LIT;
            continue;
          end;
          if (e and 16 <> 0) then begin
            c^.sub.copy.get := e and 15;
            c^.len := t^.base;
            c^.mode := LENEXT;
            continue;
          end;
          if (e and 64 = 0) then begin
            c^.sub.code.need := e;
            c^.sub.code.tree := @huft_ptr(t)^[t^.base];
            continue;
          end;
          if (e and 32 <> 0) then begin
            c^.mode := WASH;
            continue;
          end;
          c^.mode := BADCODE;
          z.msg := 'invalid literal/length code';
          r := Z_DATA_ERROR;
          s.bitb := b;
          s.bitk := k;
          z.avail_in := n;
          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
          z.next_in := p;
          s.write := q;
          inflate_codes := inflate_flush(s, z, r);
          exit;
        end;
      LENEXT:
        begin
          j := c^.sub.copy.get;
          while (k < j) do begin
            if (n <> 0) then
              r := Z_OK
            else begin
              s.bitb := b;
              s.bitk := k;
              z.avail_in := n;
              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
              z.next_in := p;
              s.write := q;
              inflate_codes := inflate_flush(s, z, r);
              exit;
            end;
            Dec(n);
            b := b or (uLong(p^) shl k);
            Inc(p);
            Inc(k, 8);
          end;
          Inc(c^.len, uInt(b and inflate_mask[j]));
          b := b shr j;
          Dec(k, j);
          c^.sub.code.need := c^.dbits;
          c^.sub.code.tree := c^.dtree;
          c^.mode := DIST;
        end;
      DIST:
        begin
          j := c^.sub.code.need;
          while (k < j) do begin
            if (n <> 0) then
              r := Z_OK
            else begin
              s.bitb := b;
              s.bitk := k;
              z.avail_in := n;
              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
              z.next_in := p;
              s.write := q;
              inflate_codes := inflate_flush(s, z, r);
              exit;
            end;
            Dec(n);
            b := b or (uLong(p^) shl k);
            Inc(p);
            Inc(k, 8);
          end;
          t := @huft_ptr(c^.sub.code.tree)^[uInt(b) and inflate_mask[j]];
          b := b shr t^.bits;
          Dec(k, t^.bits);
          e := uInt(t^.exop);
          if (e and 16 <> 0) then begin
            c^.sub.copy.get := e and 15;
            c^.sub.copy.dist := t^.base;
            c^.mode := DISTEXT;
            continue;
          end;
          if (e and 64 = 0) then begin
            c^.sub.code.need := e;
            c^.sub.code.tree := @huft_ptr(t)^[t^.base];
            continue;
          end;
          c^.mode := BADCODE;
          z.msg := 'invalid distance code';
          r := Z_DATA_ERROR;
          s.bitb := b;
          s.bitk := k;
          z.avail_in := n;
          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
          z.next_in := p;
          s.write := q;
          inflate_codes := inflate_flush(s, z, r);
          exit;
        end;
      DISTEXT:
        begin
          j := c^.sub.copy.get;
          while (k < j) do begin
            if (n <> 0) then
              r := Z_OK
            else begin
              s.bitb := b;
              s.bitk := k;
              z.avail_in := n;
              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
              z.next_in := p;
              s.write := q;
              inflate_codes := inflate_flush(s, z, r);
              exit;
            end;
            Dec(n);
            b := b or (uLong(p^) shl k);
            Inc(p);
            Inc(k, 8);
          end;
          Inc(c^.sub.copy.dist, uInt(b) and inflate_mask[j]);
          b := b shr j;
          Dec(k, j);
          c^.mode := COPY;
        end;
      COPY:
        begin
          f := q;
          Dec(f, c^.sub.copy.dist);
          if (uInt(ptr2int(q) - ptr2int(s.window)) < c^.sub.copy.dist) then begin
            f := s.zend;
            Dec(f, c^.sub.copy.dist - uInt(ptr2int(q) - ptr2int(s.window)));
          end;
          while (c^.len <> 0) do begin
            if (m = 0) then begin
              if (q = s.zend) and (s.read <> s.window) then begin
                q := s.window;
                if ptr2int(q) < ptr2int(s.read) then
                  m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
                else
                  m := uInt(ptr2int(s.zend) - ptr2int(q));
              end;
              if (m = 0) then begin
                s.write := q;
                r := inflate_flush(s, z, r);
                q := s.write;
                if ptr2int(q) < ptr2int(s.read) then
                  m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
                else
                  m := uInt(ptr2int(s.zend) - ptr2int(q));
                if (q = s.zend) and (s.read <> s.window) then begin
                  q := s.window;
                  if ptr2int(q) < ptr2int(s.read) then
                    m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
                  else
                    m := uInt(ptr2int(s.zend) - ptr2int(q));
                end;
                if (m = 0) then begin
                  s.bitb := b;
                  s.bitk := k;
                  z.avail_in := n;
                  Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
                  z.next_in := p;
                  s.write := q;
                  inflate_codes := inflate_flush(s, z, r);
                  exit;
                end;
              end;
            end;
            r := Z_OK;
            q^ := f^;
            Inc(q);
            Inc(f);
            Dec(m);
            if (f = s.zend) then
              f := s.window;
            Dec(c^.len);
          end;
          c^.mode := START;
        end;
      LIT:
        begin
          if (m = 0) then begin
            if (q = s.zend) and (s.read <> s.window) then begin
              q := s.window;
              if ptr2int(q) < ptr2int(s.read) then
                m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
              else
                m := uInt(ptr2int(s.zend) - ptr2int(q));
            end;
            if (m = 0) then begin
              s.write := q;
              r := inflate_flush(s, z, r);
              q := s.write;
              if ptr2int(q) < ptr2int(s.read) then
                m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
              else
                m := uInt(ptr2int(s.zend) - ptr2int(q));
              if (q = s.zend) and (s.read <> s.window) then begin
                q := s.window;
                if ptr2int(q) < ptr2int(s.read) then
                  m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
                else
                  m := uInt(ptr2int(s.zend) - ptr2int(q));
              end;
              if (m = 0) then begin
                s.bitb := b;
                s.bitk := k;
                z.avail_in := n;
                Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
                z.next_in := p;
                s.write := q;
                inflate_codes := inflate_flush(s, z, r);
                exit;
              end;
            end;
          end;
          r := Z_OK;
          q^ := c^.sub.lit;
          Inc(q);
          Dec(m);
          c^.mode := START;
        end;
      WASH:
        begin
          if (k > 7) then begin
            Dec(k, 8);
            Inc(n);
            Dec(p);
          end;
          s.write := q;
          r := inflate_flush(s, z, r);
          q := s.write;
          if ptr2int(q) < ptr2int(s.read) then
            m := uInt(ptr2int(s.read) - ptr2int(q) - 1)
          else
            m := uInt(ptr2int(s.zend) - ptr2int(q));
          if (s.read <> s.write) then begin
            s.bitb := b;
            s.bitk := k;
            z.avail_in := n;
            Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
            z.next_in := p;
            s.write := q;
            inflate_codes := inflate_flush(s, z, r);
            exit;
          end;
          c^.mode := ZEND;
        end;
      ZEND:
        begin
          r := Z_STREAM_END;
          s.bitb := b;
          s.bitk := k;
          z.avail_in := n;
          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
          z.next_in := p;
          s.write := q;
          inflate_codes := inflate_flush(s, z, r);
          exit;
        end;
      BADCODE:
        begin
          r := Z_DATA_ERROR;
          s.bitb := b;
          s.bitk := k;
          z.avail_in := n;
          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
          z.next_in := p;
          s.write := q;
          inflate_codes := inflate_flush(s, z, r);
          exit;
        end;
    else
      begin
        r := Z_STREAM_ERROR;
        s.bitb := b;
        s.bitk := k;
        z.avail_in := n;
        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
        z.next_in := p;
        s.write := q;
        inflate_codes := inflate_flush(s, z, r);
        exit;
      end;
    end;
  inflate_codes := Z_STREAM_ERROR;
end;

procedure inflate_codes_free(c: pInflate_codes_state;
  var z: z_stream);
begin
  ZFREE(z, c);
end;

{-----------------------------------------------------------------------------}
{-----------------------------------------------------------------------------}
{-----------------------------------------------------------------------------}

{ inftrees.h -- header to use inftrees.c
  inftrees.c -- generate Huffman trees for efficient decoding
  Copyright (C) 1995-1998 Mark Adler

  inftrees.pas -- pascal translation
  Copyright (C) 1998 by Jacques Nomssi Nzali
}

const
  MANY = 1440;

const
  LENGTH_CODES = 29;
  LITERALS = 256;
  L_CODES = (LITERALS + 1 + LENGTH_CODES);
  D_CODES = 30;
  BL_CODES = 19;
  HEAP_SIZE = (2 * L_CODES + 1);
  MAX_BITS = 15;
  INIT_STATE = 42;
  BUSY_STATE = 113;
  FINISH_STATE = 666;

type
  ct_data_ptr = ^ct_data;
  ct_data = record
    fc: record
      case byte of
        0: (freq: ush);
        1: (code: ush);
    end;
    dl: record
      case byte of

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -