"Fossies" - the Fresh Open Source Software Archive

Member "pigz-2.8/zopfli/src/zopfli/cache.h" (11 Jan 2015, 2256 Bytes) of package /linux/privat/pigz-2.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cache.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 Copyright 2011 Google Inc. All Rights Reserved.
    3 
    4 Licensed under the Apache License, Version 2.0 (the "License");
    5 you may not use this file except in compliance with the License.
    6 You may obtain a copy of the License at
    7 
    8     http://www.apache.org/licenses/LICENSE-2.0
    9 
   10 Unless required by applicable law or agreed to in writing, software
   11 distributed under the License is distributed on an "AS IS" BASIS,
   12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13 See the License for the specific language governing permissions and
   14 limitations under the License.
   15 
   16 Author: lode.vandevenne@gmail.com (Lode Vandevenne)
   17 Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
   18 */
   19 
   20 /*
   21 The cache that speeds up ZopfliFindLongestMatch of lz77.c.
   22 */
   23 
   24 #ifndef ZOPFLI_CACHE_H_
   25 #define ZOPFLI_CACHE_H_
   26 
   27 #include "util.h"
   28 
   29 #ifdef ZOPFLI_LONGEST_MATCH_CACHE
   30 
   31 /*
   32 Cache used by ZopfliFindLongestMatch to remember previously found length/dist
   33 values.
   34 This is needed because the squeeze runs will ask these values multiple times for
   35 the same position.
   36 Uses large amounts of memory, since it has to remember the distance belonging
   37 to every possible shorter-than-the-best length (the so called "sublen" array).
   38 */
   39 typedef struct ZopfliLongestMatchCache {
   40   unsigned short* length;
   41   unsigned short* dist;
   42   unsigned char* sublen;
   43 } ZopfliLongestMatchCache;
   44 
   45 /* Initializes the ZopfliLongestMatchCache. */
   46 void ZopfliInitCache(size_t blocksize, ZopfliLongestMatchCache* lmc);
   47 
   48 /* Frees up the memory of the ZopfliLongestMatchCache. */
   49 void ZopfliCleanCache(ZopfliLongestMatchCache* lmc);
   50 
   51 /* Stores sublen array in the cache. */
   52 void ZopfliSublenToCache(const unsigned short* sublen,
   53                          size_t pos, size_t length,
   54                          ZopfliLongestMatchCache* lmc);
   55 
   56 /* Extracts sublen array from the cache. */
   57 void ZopfliCacheToSublen(const ZopfliLongestMatchCache* lmc,
   58                          size_t pos, size_t length,
   59                          unsigned short* sublen);
   60 /* Returns the length up to which could be stored in the cache. */
   61 unsigned ZopfliMaxCachedSublen(const ZopfliLongestMatchCache* lmc,
   62                                size_t pos, size_t length);
   63 
   64 #endif  /* ZOPFLI_LONGEST_MATCH_CACHE */
   65 
   66 #endif  /* ZOPFLI_CACHE_H_ */