]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/simple/simple_private.h
Imported to git.
[icculus/xz.git] / src / liblzma / simple / simple_private.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       simple_private.h
4 /// \brief      Private definitions for so called simple filters
5 //
6 //  Copyright (C) 2007 Lasse Collin
7 //
8 //  This library is free software; you can redistribute it and/or
9 //  modify it under the terms of the GNU Lesser General Public
10 //  License as published by the Free Software Foundation; either
11 //  version 2.1 of the License, or (at your option) any later version.
12 //
13 //  This library is distributed in the hope that it will be useful,
14 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 //  Lesser General Public License for more details.
17 //
18 ///////////////////////////////////////////////////////////////////////////////
19
20 #ifndef LZMA_SIMPLE_PRIVATE_H
21 #define LZMA_SIMPLE_PRIVATE_H
22
23 #include "simple_coder.h"
24
25
26 typedef struct lzma_simple_s lzma_simple;
27
28 struct lzma_coder_s {
29         /// Next filter in the chain
30         lzma_next_coder next;
31
32         /// True if the next coder in the chain has returned LZMA_STREAM_END
33         /// or if we have processed uncompressed_size bytes.
34         bool end_was_reached;
35
36         /// True if filter() should encode the data; false to decode.
37         /// Currently all simple filters use the same function for encoding
38         /// and decoding, because the difference between encoders and decoders
39         /// is very small.
40         bool is_encoder;
41
42         /// Size of the data *left* to be processed, or LZMA_VLI_VALUE_UNKNOWN
43         /// if unknown.
44         lzma_vli uncompressed_size;
45
46         /// Pointer to filter-specific function, which does
47         /// the actual filtering.
48         size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
49                         bool is_encoder, uint8_t *buffer, size_t size);
50
51         /// Pointer to filter-specific data, or NULL if filter doesn't need
52         /// any extra data.
53         lzma_simple *simple;
54
55         /// The lowest 32 bits of the current position in the data. Most
56         /// filters need this to do conversions between absolute and relative
57         /// addresses.
58         uint32_t now_pos;
59
60         /// Size of the memory allocated for the buffer.
61         size_t allocated;
62
63         /// Flushing position in the temporary buffer. buffer[pos] is the
64         /// next byte to be copied to out[].
65         size_t pos;
66
67         /// buffer[filtered] is the first unfiltered byte. When pos is smaller
68         /// than filtered, there is unflushed filtered data in the buffer.
69         size_t filtered;
70
71         /// Total number of bytes (both filtered and unfiltered) currently
72         /// in the temporary buffer.
73         size_t size;
74
75         /// Temporary buffer
76         uint8_t buffer[];
77 };
78
79
80 extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
81                 lzma_allocator *allocator, const lzma_filter_info *filters,
82                 size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
83                         bool is_encoder, uint8_t *buffer, size_t size),
84                 size_t simple_size, size_t unfiltered_max, bool is_encoder);
85
86 #endif