< prev index next >

src/java.base/share/native/libzip/zlib/deflate.h

Print this page
*** 21,11 ***
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
  /* deflate.h -- internal compression state
!  * Copyright (C) 1995-2018 Jean-loup Gailly
   * For conditions of distribution and use, see copyright notice in zlib.h
   */
  
  /* WARNING: this file should *not* be used by applications. It is
     part of the implementation of the compression library and is
--- 21,11 ---
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
  /* deflate.h -- internal compression state
!  * Copyright (C) 1995-2024 Jean-loup Gailly
   * For conditions of distribution and use, see copyright notice in zlib.h
   */
  
  /* WARNING: this file should *not* be used by applications. It is
     part of the implementation of the compression library and is

*** 45,10 ***
--- 45,14 ---
     should be left enabled. */
  #ifndef NO_GZIP
  #  define GZIP
  #endif
  
+ /* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
+    the cost of a larger memory footprint */
+ /* #define LIT_MEM */
+ 
  /* ===========================================================================
   * Internal compression state.
   */
  
  #define LENGTH_CODES 29

*** 239,11 ***
--- 243,18 ---
  
      uch depth[2*L_CODES+1];
      /* Depth of each subtree used as tie breaker for trees of equal frequency
       */
  
+ #ifdef LIT_MEM
+ #   define LIT_BUFS 5
+     ushf *d_buf;          /* buffer for distances */
+     uchf *l_buf;          /* buffer for literals/lengths */
+ #else
+ #   define LIT_BUFS 4
      uchf *sym_buf;        /* buffer for distances and literals/lengths */
+ #endif
  
      uInt  lit_bufsize;
      /* Size of match buffer for literals/lengths.  There are 4 reasons for
       * limiting lit_bufsize to 64K:
       *   - frequencies can be kept in 16 bit counters

*** 261,11 ***
       *     fast adaptation but have of course the overhead of transmitting
       *     trees more frequently.
       *   - I can't count above 4
       */
  
!     uInt sym_next;      /* running index in sym_buf */
      uInt sym_end;       /* symbol table full when sym_next reaches this */
  
      ulg opt_len;        /* bit length of current block with optimal trees */
      ulg static_len;     /* bit length of current block with static trees */
      uInt matches;       /* number of string matches in current block */
--- 272,11 ---
       *     fast adaptation but have of course the overhead of transmitting
       *     trees more frequently.
       *   - I can't count above 4
       */
  
!     uInt sym_next;      /* running index in symbol buffer */
      uInt sym_end;       /* symbol table full when sym_next reaches this */
  
      ulg opt_len;        /* bit length of current block with optimal trees */
      ulg static_len;     /* bit length of current block with static trees */
      uInt matches;       /* number of string matches in current block */

*** 313,18 ***
  #define WIN_INIT MAX_MATCH
  /* Number of bytes after end of data in window to initialize in order to avoid
     memory checker errors from longest match routines */
  
          /* in trees.c */
! void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
! int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
! void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
!                         ulg stored_len, int last));
! void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
! void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
! void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
!                         ulg stored_len, int last));
  
  #define d_code(dist) \
     ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
  /* Mapping from a distance to a distance code. dist is the distance - 1 and
   * must not have side effects. _dist_code[256] and _dist_code[257] are never
--- 324,18 ---
  #define WIN_INIT MAX_MATCH
  /* Number of bytes after end of data in window to initialize in order to avoid
     memory checker errors from longest match routines */
  
          /* in trees.c */
! void ZLIB_INTERNAL _tr_init(deflate_state *s);
! int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
! void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
!                                    ulg stored_len, int last);
! void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
! void ZLIB_INTERNAL _tr_align(deflate_state *s);
! void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
!                                     ulg stored_len, int last);
  
  #define d_code(dist) \
     ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
  /* Mapping from a distance to a distance code. dist is the distance - 1 and
   * must not have side effects. _dist_code[256] and _dist_code[257] are never

*** 340,10 ***
--- 351,29 ---
  #else
    extern const uch ZLIB_INTERNAL _length_code[];
    extern const uch ZLIB_INTERNAL _dist_code[];
  #endif
  
+ #ifdef LIT_MEM
+ # define _tr_tally_lit(s, c, flush) \
+   { uch cc = (c); \
+     s->d_buf[s->sym_next] = 0; \
+     s->l_buf[s->sym_next++] = cc; \
+     s->dyn_ltree[cc].Freq++; \
+     flush = (s->sym_next == s->sym_end); \
+    }
+ # define _tr_tally_dist(s, distance, length, flush) \
+   { uch len = (uch)(length); \
+     ush dist = (ush)(distance); \
+     s->d_buf[s->sym_next] = dist; \
+     s->l_buf[s->sym_next++] = len; \
+     dist--; \
+     s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
+     s->dyn_dtree[d_code(dist)].Freq++; \
+     flush = (s->sym_next == s->sym_end); \
+   }
+ #else
  # define _tr_tally_lit(s, c, flush) \
    { uch cc = (c); \
      s->sym_buf[s->sym_next++] = 0; \
      s->sym_buf[s->sym_next++] = 0; \
      s->sym_buf[s->sym_next++] = cc; \

*** 359,10 ***
--- 389,11 ---
      dist--; \
      s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
      s->dyn_dtree[d_code(dist)].Freq++; \
      flush = (s->sym_next == s->sym_end); \
    }
+ #endif
  #else
  # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
  # define _tr_tally_dist(s, distance, length, flush) \
                flush = _tr_tally(s, distance, length)
  #endif
< prev index next >