1/*
2Copyright (c) 2015-2016, Apple Inc. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
61. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
82. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
9 in the documentation and/or other materials provided with the distribution.
10
113. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived
12 from this software without specific prior written permission.
13
14THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
16COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20*/
21
22// LZVN low-level decoder (v2)
23// Functions in the low-level API should switch to these at some point.
24// Apr 2014
25
26#ifndef LZVN_DECODE_BASE_H
27#define LZVN_DECODE_BASE_H
28
29#include "lzfse_internal.h"
30
31/*! @abstract Base decoder state. */
32typedef struct {
33
34 // Decoder I/O
35
36 // Next byte to read in source buffer
37 const unsigned char *src;
38 // Next byte after source buffer
39 const unsigned char *src_end;
40
41 // Next byte to write in destination buffer (by decoder)
42 unsigned char *dst;
43 // Valid range for destination buffer is [dst_begin, dst_end - 1]
44 unsigned char *dst_begin;
45 unsigned char *dst_end;
46 // Next byte to read in destination buffer (modified by caller)
47 unsigned char *dst_current;
48
49 // Decoder state
50
51 // Partially expanded match, or 0,0,0.
52 // In that case, src points to the next literal to copy, or the next op-code
53 // if L==0.
54 size_t L, M, D;
55
56 // Distance for last emitted match, or 0
57 lzvn_offset d_prev;
58
59 // Did we decode end-of-stream?
60 int end_of_stream;
61
62} lzvn_decoder_state;
63
64/*! @abstract Decode source to destination.
65 * Updates \p state (src,dst,d_prev). */
66void lzvn_decode(lzvn_decoder_state *state);
67
68#endif // LZVN_DECODE_BASE_H
69