aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/api/lzma
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/liblzma/api/lzma/block.h47
-rw-r--r--src/liblzma/api/lzma/filter.h8
-rw-r--r--src/liblzma/api/lzma/index.h20
-rw-r--r--src/liblzma/api/lzma/index_hash.h4
4 files changed, 55 insertions, 24 deletions
diff --git a/src/liblzma/api/lzma/block.h b/src/liblzma/api/lzma/block.h
index eb3768e2..06c1633c 100644
--- a/src/liblzma/api/lzma/block.h
+++ b/src/liblzma/api/lzma/block.h
@@ -1,6 +1,6 @@
/**
* \file lzma/block.h
- * \brief .lzma Block handling
+ * \brief .xz Block handling
*
* \author Copyright (C) 1999-2006 Igor Pavlov
* \author Copyright (C) 2007 Lasse Collin
@@ -131,11 +131,10 @@ typedef struct {
*
* \note Because of the array is terminated with
* .id = LZMA_VLI_UNKNOWN, the actual array must
- * have LZMA_BLOCK_FILTERS_MAX + 1 members or the Block
+ * have LZMA_FILTERS_MAX + 1 members or the Block
* Header decoder will overflow the buffer.
*/
lzma_filter *filters;
-# define LZMA_BLOCK_FILTERS_MAX 4
} lzma_block;
@@ -148,6 +147,8 @@ typedef struct {
* The size can be calculated from the first byte of a Block using this macro.
* Note that if the first byte is 0x00, it indicates beginning of Index; use
* this macro only when the byte is not 0x00.
+ *
+ * There is no encoding macro, because Block Header encoder is enough for that.
*/
#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
@@ -211,38 +212,50 @@ extern lzma_ret lzma_block_header_decode(lzma_block *options,
/**
- * \brief Sets Compressed Size according to Total Size
+ * \brief Sets Compressed Size according to Unpadded Size
*
- * Block Header stores Compressed Size, but Index has Total Size. If the
+ * Block Header stores Compressed Size, but Index has Unpadded Size. If the
* application has already parsed the Index and is now decoding Blocks,
- * it can calculate Compressed Size from Total Size. This function does
+ * it can calculate Compressed Size from Unpadded Size. This function does
* exactly that with error checking, so application doesn't need to check,
* for example, if the value in Index is too small to contain even the
- * Block Header. Note that you need to call this function after decoding
+ * Block Header. Note that you need to call this function _after_ decoding
* the Block Header field.
*
* \return - LZMA_OK: options->compressed_size was set successfully.
- * - LZMA_DATA_ERROR: total_size is too small compared to
+ * - LZMA_DATA_ERROR: unpadded_size is too small compared to
* options->header_size and lzma_check_sizes[options->check].
* - LZMA_PROG_ERROR: Some values are invalid. For example,
- * total_size and options->header_size must be multiples
- * of four, total_size must be at least 12, and
+ * options->header_size must be a multiple of four, and
* options->header_size between 8 and 1024 inclusive.
*/
-extern lzma_ret lzma_block_total_size_set(
- lzma_block *options, lzma_vli total_size)
+extern lzma_ret lzma_block_compressed_size(
+ lzma_block *options, lzma_vli unpadded_size)
lzma_attr_warn_unused_result;
/**
- * \brief Calculates Total Size
+ * \brief Calculates Unpadded Size
*
- * This function can be useful after decoding a Block to get Total Size
+ * This function can be useful after decoding a Block to get Unpadded Size
* that is stored in Index.
*
- * \return Total Size on success, or zero on error.
+ * \return Unpadded Size on success, or zero on error.
+ */
+extern lzma_vli lzma_block_unpadded_size(const lzma_block *options)
+ lzma_attr_pure;
+
+
+/**
+ * \brief Calculates the total encoded size of a Block
+ *
+ * This is equivalent to lzma_block_unpadded_size() except that the returned
+ * value includes the size of the Block Padding field.
+ *
+ * \return On success, total encoded size of the Block. On error,
+ * zero is returned.
*/
-extern lzma_vli lzma_block_total_size_get(const lzma_block *options)
+extern lzma_vli lzma_block_total_size(const lzma_block *options)
lzma_attr_pure;
@@ -255,8 +268,6 @@ extern lzma_vli lzma_block_total_size_get(const lzma_block *options)
* \return - LZMA_OK: All good, continue with lzma_code().
* - LZMA_MEM_ERROR
* - LZMA_OPTIONS_ERROR
- * - LZMA_DATA_ERROR: Limits (total_limit and uncompressed_limit)
- * have been reached already.
* - LZMA_UNSUPPORTED_CHECK: options->check specfies a Check
* that is not supported by this buid of liblzma. Initializing
* the encoder failed.
diff --git a/src/liblzma/api/lzma/filter.h b/src/liblzma/api/lzma/filter.h
index 53e5737e..b4fb02a7 100644
--- a/src/liblzma/api/lzma/filter.h
+++ b/src/liblzma/api/lzma/filter.h
@@ -55,6 +55,14 @@ typedef struct {
/**
+ * \brief Maximum number of filters in a chain
+ *
+ * FIXME desc
+ */
+#define LZMA_FILTERS_MAX 4
+
+
+/**
* \brief Test if the given Filter ID is supported for encoding
*
* Returns true if the give Filter ID is supported for encoding by this
diff --git a/src/liblzma/api/lzma/index.h b/src/liblzma/api/lzma/index.h
index 522969d4..d6072614 100644
--- a/src/liblzma/api/lzma/index.h
+++ b/src/liblzma/api/lzma/index.h
@@ -32,12 +32,24 @@ typedef struct lzma_index_s lzma_index;
*/
typedef struct {
/**
- * Total Size of a Block.
+ * \brief Total encoded size of a Block including Block Padding
+ *
+ * This value is useful if you need to know the actual size of the
+ * Block that the Block decoder will read.
*/
lzma_vli total_size;
/**
- * Uncompressed Size of a Block
+ * \brief Encoded size of a Block excluding Block Padding
+ *
+ * This value is stored in the Index. When doing random-access
+ * reading, you should give this value to the Block decoder along
+ * with uncompressed_size.
+ */
+ lzma_vli unpadded_size;
+
+ /**
+ * \brief Uncompressed Size of a Block
*/
lzma_vli uncompressed_size;
@@ -80,7 +92,7 @@ extern void lzma_index_end(lzma_index *i, lzma_allocator *allocator);
* \brief Add a new Record to an Index
*
* \param index Pointer to a lzma_index structure
- * \param total_size Total Size of a Block
+ * \param unpadded_size Unpadded Size of a Block
* \param uncompressed_size Uncompressed Size of a Block, or
* LZMA_VLI_UNKNOWN to indicate padding.
*
@@ -92,7 +104,7 @@ extern void lzma_index_end(lzma_index *i, lzma_allocator *allocator);
* - LZMA_PROG_ERROR
*/
extern lzma_ret lzma_index_append(lzma_index *i, lzma_allocator *allocator,
- lzma_vli total_size, lzma_vli uncompressed_size)
+ lzma_vli unpadded_size, lzma_vli uncompressed_size)
lzma_attr_warn_unused_result;
diff --git a/src/liblzma/api/lzma/index_hash.h b/src/liblzma/api/lzma/index_hash.h
index 58fc8061..001e6b5c 100644
--- a/src/liblzma/api/lzma/index_hash.h
+++ b/src/liblzma/api/lzma/index_hash.h
@@ -57,7 +57,7 @@ extern void lzma_index_hash_end(
* \brief Add a new Record to an Index hash
*
* \param index Pointer to a lzma_index_hash structure
- * \param total_size Total Size of a Block
+ * \param unpadded_size Unpadded Size of a Block
* \param uncompressed_size Uncompressed Size of a Block
*
* \return - LZMA_OK
@@ -67,7 +67,7 @@ extern void lzma_index_hash_end(
* used when lzma_index_hash_decode() has already been used.
*/
extern lzma_ret lzma_index_hash_append(lzma_index_hash *index_hash,
- lzma_vli total_size, lzma_vli uncompressed_size)
+ lzma_vli unpadded_size, lzma_vli uncompressed_size)
lzma_attr_warn_unused_result;