aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/api/lzma
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-11-14 18:59:19 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-11-14 18:59:19 +0200
commit418d64a32e8144210f98a810738fed5a897e8367 (patch)
treee3dce06dfd250fd659d922aaed914f6cc93cd2c8 /src/liblzma/api/lzma
parentFix wrong function name in the previous commit. (diff)
downloadxz-418d64a32e8144210f98a810738fed5a897e8367.tar.xz
Fix a design error in liblzma API.
Originally the idea was that using LZMA_FULL_FLUSH with Stream encoder would read the filter chain from the same array that was used to intialize the Stream encoder. Since most apps wouldn't use LZMA_FULL_FLUSH, most apps wouldn't need to keep the filter chain available after initializing the Stream encoder. However, due to my mistake, it actually required keeping the array always available. Since setting the new filter chain via the array used at initialization time is not a nice way to do it for a couple of reasons, this commit ditches it and introduces lzma_filters_update(). This new function replaces also the "persistent" flag used by LZMA2 (and to-be-designed Subblock filter), which was also an ugly thing to do. Thanks to Alexey Tourbin for reminding me about the problem that Stream encoder used to require keeping the filter chain allocated.
Diffstat (limited to 'src/liblzma/api/lzma')
-rw-r--r--src/liblzma/api/lzma/filter.h30
-rw-r--r--src/liblzma/api/lzma/lzma.h13
2 files changed, 30 insertions, 13 deletions
diff --git a/src/liblzma/api/lzma/filter.h b/src/liblzma/api/lzma/filter.h
index c4bc69d3..01393dd4 100644
--- a/src/liblzma/api/lzma/filter.h
+++ b/src/liblzma/api/lzma/filter.h
@@ -198,6 +198,36 @@ extern LZMA_API(lzma_ret) lzma_raw_decoder(
/**
+ * \brief Update the filter chain in the encoder
+ *
+ * This function is for advanced users only. This function has two slightly
+ * different purposes:
+ *
+ * - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter
+ * chain, which will be used starting from the next Block.
+ *
+ * - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change
+ * the filter-specific options in the middle of encoding. The actual
+ * filters in the chain (Filter IDs) cannot be changed. In the future,
+ * it might become possible to change the filter options without
+ * using LZMA_SYNC_FLUSH.
+ *
+ * While rarely useful, this function may be called also when no data has
+ * been compressed yet. In that case, this function will behave as if
+ * LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block
+ * encoder) had been used right before calling this function.
+ *
+ * \return - LZMA_OK
+ * - LZMA_MEM_ERROR
+ * - LZMA_MEMLIMIT_ERROR
+ * - LZMA_OPTIONS_ERROR
+ * - LZMA_PROG_ERROR
+ */
+extern LZMA_API(lzma_ret) lzma_filters_update(
+ lzma_stream *strm, const lzma_filter *filters);
+
+
+/**
* \brief Single-call raw encoder
*
* \param filters Array of lzma_filter structures. The end of the
diff --git a/src/liblzma/api/lzma/lzma.h b/src/liblzma/api/lzma/lzma.h
index 28ebbb14..989425e3 100644
--- a/src/liblzma/api/lzma/lzma.h
+++ b/src/liblzma/api/lzma/lzma.h
@@ -298,19 +298,6 @@ typedef struct {
# define LZMA_PB_MAX 4
# define LZMA_PB_DEFAULT 2
- /**
- * \brief Indicate if the options structure is persistent
- *
- * If this is true, the application must keep this options structure
- * available after the LZMA2 encoder has been initialized. With
- * persistent structure it is possible to change some encoder options
- * in the middle of the encoding process without resetting the encoder.
- *
- * This option is used only by LZMA2. LZMA1 ignores this and it is
- * safe to not initialize this when encoding with LZMA1.
- */
- lzma_bool persistent;
-
/** Compression mode */
lzma_mode mode;