#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) |
#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 | ( | b | ) |
Value:
do { \ assert(*out_pos < out_size); \ out[*out_pos] = b; \ ++*out_pos; \ ++coder->alignment.out_pos; \ } while (0)
Referenced by subblock_align().
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 MIN_CHUNK_SIZE_FOR_ALIGN, 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.
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. |
static void subblock_rle_flush | ( | lzma_coder * | coder | ) | [static] |
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_alloc(), LZMA_MEM_ERROR, LZMA_OK, and LZMA_OPTIONS_ERROR.