From 4810b6bc25087be872960b9dd1d11ff07735dc88 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 19 Jan 2009 14:00:33 +0200 Subject: Move some LZMA2 constants to lzma2_encoder.h so that they can be used outside lzma2_encoder.c. --- src/liblzma/lzma/lzma2_encoder.c | 13 ------------- src/liblzma/lzma/lzma2_encoder.h | 14 ++++++++++++++ src/liblzma/lzma/lzma_encoder.c | 3 ++- 3 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/liblzma/lzma/lzma2_encoder.c b/src/liblzma/lzma/lzma2_encoder.c index 09a2f2e9..81b6f973 100644 --- a/src/liblzma/lzma/lzma2_encoder.c +++ b/src/liblzma/lzma/lzma2_encoder.c @@ -24,19 +24,6 @@ #include "lzma2_encoder.h" -/// Maximum number of bytes of actual data per chunk (no headers) -#define LZMA2_CHUNK_MAX (UINT32_C(1) << 16) - -/// Maximum uncompressed size of LZMA chunk (no headers) -#define LZMA2_UNCOMPRESSED_MAX (UINT32_C(1) << 21) - -/// Maximum size of LZMA2 headers -#define LZMA2_HEADER_MAX 6 - -/// Size of a header for uncompressed chunk -#define LZMA2_HEADER_UNCOMPRESSED 3 - - struct lzma_coder_s { enum { SEQ_INIT, diff --git a/src/liblzma/lzma/lzma2_encoder.h b/src/liblzma/lzma/lzma2_encoder.h index 3e27f680..7c86ad46 100644 --- a/src/liblzma/lzma/lzma2_encoder.h +++ b/src/liblzma/lzma/lzma2_encoder.h @@ -23,6 +23,20 @@ #include "common.h" + +/// Maximum number of bytes of actual data per chunk (no headers) +#define LZMA2_CHUNK_MAX (UINT32_C(1) << 16) + +/// Maximum uncompressed size of LZMA chunk (no headers) +#define LZMA2_UNCOMPRESSED_MAX (UINT32_C(1) << 21) + +/// Maximum size of LZMA2 headers +#define LZMA2_HEADER_MAX 6 + +/// Size of a header for uncompressed chunk +#define LZMA2_HEADER_UNCOMPRESSED 3 + + extern lzma_ret lzma_lzma2_encoder_init( lzma_next_coder *next, lzma_allocator *allocator, const lzma_filter_info *filters); diff --git a/src/liblzma/lzma/lzma_encoder.c b/src/liblzma/lzma/lzma_encoder.c index 70fd93eb..79bb8f9b 100644 --- a/src/liblzma/lzma/lzma_encoder.c +++ b/src/liblzma/lzma/lzma_encoder.c @@ -18,6 +18,7 @@ // /////////////////////////////////////////////////////////////////////////////// +#include "lzma2_encoder.h" #include "lzma_encoder_private.h" #include "fastpos.h" @@ -342,7 +343,7 @@ lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, if (limit != UINT32_MAX && (mf->read_pos - mf->read_ahead >= limit || *out_pos + rc_pending(&coder->rc) - >= (UINT32_C(1) << 16) + >= LZMA2_CHUNK_MAX - LOOP_INPUT_MAX)) break; -- cgit v1.2.3