aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/simple
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-06-18 18:02:10 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-06-18 18:02:10 +0300
commit7d17818cec8597f847b0a2537fde991bbc3d9e96 (patch)
tree9c41502e3eb96f103fe98e13456b382fbba7a292 /src/liblzma/simple
parentUpdate the file format specification draft. The new one is (diff)
downloadxz-7d17818cec8597f847b0a2537fde991bbc3d9e96.tar.xz
Update the code to mostly match the new simpler file format
specification. Simplify things by removing most of the support for known uncompressed size in most places. There are some miscellaneous changes here and there too. The API of liblzma has got many changes and still some more will be done soon. While most of the code has been updated, some things are not fixed (the command line tool will choke with invalid filter chain, if nothing else). Subblock filter is somewhat broken for now. It will be updated once the encoded format of the Subblock filter has been decided.
Diffstat (limited to 'src/liblzma/simple')
-rw-r--r--src/liblzma/simple/simple_coder.c29
-rw-r--r--src/liblzma/simple/simple_private.h4
2 files changed, 4 insertions, 29 deletions
diff --git a/src/liblzma/simple/simple_coder.c b/src/liblzma/simple/simple_coder.c
index e9674308..078f1b95 100644
--- a/src/liblzma/simple/simple_coder.c
+++ b/src/liblzma/simple/simple_coder.c
@@ -23,11 +23,7 @@
#include "simple_private.h"
-/// Copied or encodes/decodes more data to out[]. Checks and updates
-/// uncompressed_size when we are the last coder in the chain.
-/// If we aren't the last filter in the chain, we don't need to care about
-/// uncompressed size, since we don't change it; the next filter in the
-/// chain will check it anyway.
+/// Copied or encodes/decodes more data to out[].
static lzma_ret
copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
const uint8_t *restrict in, size_t *restrict in_pos,
@@ -37,28 +33,12 @@ copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
assert(!coder->end_was_reached);
if (coder->next.code == NULL) {
- const size_t in_avail = in_size - *in_pos;
-
- if (!coder->is_encoder) {
- // Limit in_size so that we don't copy too much.
- if ((lzma_vli)(in_avail) > coder->uncompressed_size)
- in_size = *in_pos + (size_t)(
- coder->uncompressed_size);
- }
-
- const size_t out_start = *out_pos;
bufcpy(in, in_pos, in_size, out, out_pos, out_size);
// Check if end of stream was reached.
- if (coder->is_encoder) {
- if (action == LZMA_FINISH && *in_pos == in_size)
- coder->end_was_reached = true;
- } else if (coder->uncompressed_size
- != LZMA_VLI_VALUE_UNKNOWN) {
- coder->uncompressed_size -= *out_pos - out_start;
- if (coder->uncompressed_size == 0)
- coder->end_was_reached = true;
- }
+ if (coder->is_encoder && action == LZMA_FINISH
+ && *in_pos == in_size)
+ coder->end_was_reached = true;
} else {
// Call the next coder in the chain to provide us some data.
@@ -283,7 +263,6 @@ lzma_simple_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
// Reset variables.
next->coder->is_encoder = is_encoder;
next->coder->end_was_reached = false;
- next->coder->uncompressed_size = filters[0].uncompressed_size;
next->coder->pos = 0;
next->coder->filtered = 0;
next->coder->size = 0;
diff --git a/src/liblzma/simple/simple_private.h b/src/liblzma/simple/simple_private.h
index a512396c..4e7a9db3 100644
--- a/src/liblzma/simple/simple_private.h
+++ b/src/liblzma/simple/simple_private.h
@@ -39,10 +39,6 @@ struct lzma_coder_s {
/// is very small.
bool is_encoder;
- /// Size of the data *left* to be processed, or LZMA_VLI_VALUE_UNKNOWN
- /// if unknown.
- lzma_vli uncompressed_size;
-
/// Pointer to filter-specific function, which does
/// the actual filtering.
size_t (*filter)(lzma_simple *simple, uint32_t now_pos,