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 19312518Sdelphijtypedef struct { 20207753Smm /// Next filter in the chain 21207753Smm lzma_next_coder next; 22207753Smm 23244601Smm /// True if the next coder in the chain has returned LZMA_STREAM_END. 24207753Smm bool end_was_reached; 25207753Smm 26207753Smm /// True if filter() should encode the data; false to decode. 27207753Smm /// Currently all simple filters use the same function for encoding 28207753Smm /// and decoding, because the difference between encoders and decoders 29207753Smm /// is very small. 30207753Smm bool is_encoder; 31207753Smm 32207753Smm /// Pointer to filter-specific function, which does 33207753Smm /// the actual filtering. 34312518Sdelphij size_t (*filter)(void *simple, uint32_t now_pos, 35207753Smm bool is_encoder, uint8_t *buffer, size_t size); 36207753Smm 37207753Smm /// Pointer to filter-specific data, or NULL if filter doesn't need 38207753Smm /// any extra data. 39312518Sdelphij void *simple; 40207753Smm 41207753Smm /// The lowest 32 bits of the current position in the data. Most 42207753Smm /// filters need this to do conversions between absolute and relative 43207753Smm /// addresses. 44207753Smm uint32_t now_pos; 45207753Smm 46207753Smm /// Size of the memory allocated for the buffer. 47207753Smm size_t allocated; 48207753Smm 49207753Smm /// Flushing position in the temporary buffer. buffer[pos] is the 50207753Smm /// next byte to be copied to out[]. 51207753Smm size_t pos; 52207753Smm 53207753Smm /// buffer[filtered] is the first unfiltered byte. When pos is smaller 54207753Smm /// than filtered, there is unflushed filtered data in the buffer. 55207753Smm size_t filtered; 56207753Smm 57207753Smm /// Total number of bytes (both filtered and unfiltered) currently 58207753Smm /// in the temporary buffer. 59207753Smm size_t size; 60207753Smm 61207753Smm /// Temporary buffer 62207753Smm uint8_t buffer[]; 63312518Sdelphij} lzma_simple_coder; 64207753Smm 65207753Smm 66207753Smmextern lzma_ret lzma_simple_coder_init(lzma_next_coder *next, 67292588Sdelphij const lzma_allocator *allocator, 68292588Sdelphij const lzma_filter_info *filters, 69312518Sdelphij size_t (*filter)(void *simple, uint32_t now_pos, 70207753Smm bool is_encoder, uint8_t *buffer, size_t size), 71207753Smm size_t simple_size, size_t unfiltered_max, 72207753Smm uint32_t alignment, bool is_encoder); 73207753Smm 74207753Smm#endif 75