1207753Smm///////////////////////////////////////////////////////////////////////////////
2207753Smm//
3207753Smm/// \file       simple_private.h
4207753Smm/// \brief      Private definitions for so called simple filters
5207753Smm//
6207753Smm//  Author:     Lasse Collin
7207753Smm//
8207753Smm//  This file has been put into the public domain.
9207753Smm//  You can do whatever you want with this file.
10207753Smm//
11207753Smm///////////////////////////////////////////////////////////////////////////////
12207753Smm
13207753Smm#ifndef LZMA_SIMPLE_PRIVATE_H
14207753Smm#define LZMA_SIMPLE_PRIVATE_H
15207753Smm
16207753Smm#include "simple_coder.h"
17207753Smm
18207753Smm
19207753Smmtypedef struct lzma_simple_s lzma_simple;
20207753Smm
21207753Smmstruct lzma_coder_s {
22207753Smm	/// Next filter in the chain
23207753Smm	lzma_next_coder next;
24207753Smm
25245128Smm	/// True if the next coder in the chain has returned LZMA_STREAM_END.
26207753Smm	bool end_was_reached;
27207753Smm
28207753Smm	/// True if filter() should encode the data; false to decode.
29207753Smm	/// Currently all simple filters use the same function for encoding
30207753Smm	/// and decoding, because the difference between encoders and decoders
31207753Smm	/// is very small.
32207753Smm	bool is_encoder;
33207753Smm
34207753Smm	/// Pointer to filter-specific function, which does
35207753Smm	/// the actual filtering.
36207753Smm	size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
37207753Smm			bool is_encoder, uint8_t *buffer, size_t size);
38207753Smm
39207753Smm	/// Pointer to filter-specific data, or NULL if filter doesn't need
40207753Smm	/// any extra data.
41207753Smm	lzma_simple *simple;
42207753Smm
43207753Smm	/// The lowest 32 bits of the current position in the data. Most
44207753Smm	/// filters need this to do conversions between absolute and relative
45207753Smm	/// addresses.
46207753Smm	uint32_t now_pos;
47207753Smm
48207753Smm	/// Size of the memory allocated for the buffer.
49207753Smm	size_t allocated;
50207753Smm
51207753Smm	/// Flushing position in the temporary buffer. buffer[pos] is the
52207753Smm	/// next byte to be copied to out[].
53207753Smm	size_t pos;
54207753Smm
55207753Smm	/// buffer[filtered] is the first unfiltered byte. When pos is smaller
56207753Smm	/// than filtered, there is unflushed filtered data in the buffer.
57207753Smm	size_t filtered;
58207753Smm
59207753Smm	/// Total number of bytes (both filtered and unfiltered) currently
60207753Smm	/// in the temporary buffer.
61207753Smm	size_t size;
62207753Smm
63207753Smm	/// Temporary buffer
64207753Smm	uint8_t buffer[];
65207753Smm};
66207753Smm
67207753Smm
68207753Smmextern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
69207753Smm		lzma_allocator *allocator, const lzma_filter_info *filters,
70207753Smm		size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
71207753Smm			bool is_encoder, uint8_t *buffer, size_t size),
72207753Smm		size_t simple_size, size_t unfiltered_max,
73207753Smm		uint32_t alignment, bool is_encoder);
74207753Smm
75207753Smm#endif
76