/build/buildd/xz-utils-4.999.9beta+20091116/src/liblzma/subblock/subblock_encoder.c File Reference

Encoder of the Subblock filter. More...

#include "subblock_encoder.h"
#include "filter_encoder.h"

Data Structures

struct  lzma_coder_s

Defines

#define REPEAT_COUNT_MAX   (1U << 28)
#define MIN_CHUNK_SIZE_FOR_ALIGN   4
#define ALIGN_SKEW_DATA   4
#define ALIGN_SKEW_REPEATING_DATA   5
 Like above but for Repeating Data.
#define write_byte(b)
 Writes one byte to output buffer and updates the alignment counter.

Functions

static bool subblock_align (lzma_coder *coder, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, size_t chunk_size, uint32_t skew)
 Aligns the output buffer.
static bool is_repeating (const uint8_t *restrict needle, size_t needle_size, const uint8_t *restrict buf, size_t buf_chunks)
 Checks if buffer contains repeated data.
static void subblock_rle_flush (lzma_coder *coder)
 Optimizes the repeating style and updates coder->sequence.
static lzma_ret subblock_data_size (lzma_coder *coder, lzma_allocator *allocator, size_t new_limit)
 Resizes coder->subblock.data for a new size limit.
static lzma_ret subblock_buffer (lzma_coder *coder, lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action)
static lzma_ret subblock_encode (lzma_coder *coder, lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action)
static void subblock_encoder_end (lzma_coder *coder, lzma_allocator *allocator)
lzma_ret lzma_subblock_encoder_init (lzma_next_coder *next, lzma_allocator *allocator, const lzma_filter_info *filters)

Detailed Description

Encoder of the Subblock filter.


Define Documentation

#define REPEAT_COUNT_MAX   (1U << 28)

Maximum number of repeats that a single Repeating Data can indicate. This is directly from the file format specification.

Referenced by subblock_rle_flush().

#define MIN_CHUNK_SIZE_FOR_ALIGN   4

Number of bytes the data chunk (not including the header part) must be before we care about alignment. This is somewhat arbitrary. It just doesn't make sense to waste bytes for alignment when the data chunk is very small.

Referenced by subblock_align().

#define ALIGN_SKEW_DATA   4

Number of bytes of the header part of Subblock Type `Data'. This is used as the `skew' argument for subblock_align().

#define ALIGN_SKEW_REPEATING_DATA   5

Like above but for Repeating Data.

#define write_byte (  ) 
Value:
do { \
        assert(*out_pos < out_size); \
        out[*out_pos] = b; \
        ++*out_pos; \
        ++coder->alignment.out_pos; \
} while (0)

Writes one byte to output buffer and updates the alignment counter.

Referenced by subblock_align().


Function Documentation

static bool subblock_align ( lzma_coder coder,
uint8_t *restrict  out,
size_t *restrict  out_pos,
size_t  out_size,
size_t  chunk_size,
uint32_t  skew 
) [static]

Aligns the output buffer.

Aligns the output buffer so that after skew bytes the output position is a multiple of coder->alignment.multiple.

References lzma_coder_s::in_pos, MIN_CHUNK_SIZE_FOR_ALIGN, lzma_coder_s::multiple, lzma_coder_s::out_pos, and write_byte.

static bool is_repeating ( const uint8_t *restrict  needle,
size_t  needle_size,
const uint8_t *restrict  buf,
size_t  buf_chunks 
) [static]

Checks if buffer contains repeated data.

Parameters:
needle Buffer containing a single repeat chunk
needle_size Size of needle in bytes
buf Buffer to search for repeated needles
buf_chunks Buffer size is buf_chunks * needle_size.
Returns:
True if the whole buf is filled with repeated needles.
static void subblock_rle_flush ( lzma_coder coder  )  [static]

Optimizes the repeating style and updates coder->sequence.

References lzma_coder_s::buffer, lzma_coder_s::count, REPEAT_COUNT_MAX, lzma_coder_s::size, and lzma_coder_s::tmp.

static lzma_ret subblock_data_size ( lzma_coder coder,
lzma_allocator allocator,
size_t  new_limit 
) [static]

Resizes coder->subblock.data for a new size limit.

References lzma_coder_s::data, lzma_coder_s::limit, lzma_alloc(), LZMA_MEM_ERROR, LZMA_OK, and LZMA_OPTIONS_ERROR.


Generated on Mon Dec 21 22:54:41 2009 for XZ Utils by  doxygen 1.6.1