git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-support/gbcompress/zx0/zx0_matchfinder.h

      1 /*
      2  * matchfinder.h - LZ match finder definitions
      3  *
      4  * Copyright (C) 2021 Emmanuel Marty
      5  *
      6  * This software is provided 'as-is', without any express or implied
      7  * warranty.  In no event will the authors be held liable for any damages
      8  * arising from the use of this software.
      9  *
     10  * Permission is granted to anyone to use this software for any purpose,
     11  * including commercial applications, and to alter it and redistribute it
     12  * freely, subject to the following restrictions:
     13  *
     14  * 1. The origin of this software must not be misrepresented; you must not
     15  *    claim that you wrote the original software. If you use this software
     16  *    in a product, an acknowledgment in the product documentation would be
     17  *    appreciated but is not required.
     18  * 2. Altered source versions must be plainly marked as such, and must not be
     19  *    misrepresented as being the original software.
     20  * 3. This notice may not be removed or altered from any source distribution.
     21  */
     22 
     23 /*
     24  * Uses the libdivsufsort library Copyright (c) 2003-2008 Yuta Mori
     25  *
     26  * Implements the ZX0 encoding designed by Einar Saukas. https://github.com/einar-saukas/ZX0
     27  * Also inspired by Charles Bloom's compression blog. http://cbloomrants.blogspot.com/
     28  *
     29  */
     30 
     31 #ifndef _MATCHFINDER_H
     32 #define _MATCHFINDER_H
     33 
     34 #include "zx0_shrink.h"
     35 
     36 #ifdef __cplusplus
     37 extern "C" {
     38 #endif
     39 
     40 /**
     41  * Parse input data, build suffix array and overlaid data structures to speed up match finding
     42  *
     43  * @param pCompressor compression context
     44  * @param pInWindow pointer to input data window (previously compressed bytes + bytes to compress)
     45  * @param nInWindowSize total input size in bytes (previously compressed bytes + bytes to compress)
     46  *
     47  * @return 0 for success, non-zero for failure
     48  */
     49 int salvador_build_suffix_array(salvador_compressor *pCompressor, const unsigned char *pInWindow, const int nInWindowSize);
     50 
     51 /**
     52  * Skip previously compressed bytes
     53  *
     54  * @param pCompressor compression context
     55  * @param nStartOffset current offset in input window (typically 0)
     56  * @param nEndOffset offset to skip to in input window (typically the number of previously compressed bytes)
     57  */
     58 void salvador_skip_matches(salvador_compressor *pCompressor, const int nStartOffset, const int nEndOffset);
     59 
     60 /**
     61  * Find all matches for the data to be compressed
     62  *
     63  * @param pCompressor compression context
     64  * @param nMatchesPerOffset maximum number of matches to store for each offset
     65  * @param nStartOffset current offset in input window (typically the number of previously compressed bytes)
     66  * @param nEndOffset offset to end finding matches at (typically the size of the total input window in bytes
     67  */
     68 void salvador_find_all_matches(salvador_compressor *pCompressor, const int nMatchesPerOffset, const int nStartOffset, const int nEndOffset);
     69 
     70 #ifdef __cplusplus
     71 }
     72 #endif
     73 
     74 #endif /* _MATCHFINDER_H */

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.