]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/api/lzma/easy.h
Fix test_filter_flags to match the new restriction of lc+lp.
[icculus/xz.git] / src / liblzma / api / lzma / easy.h
1 /**
2  * \file        lzma/easy.h
3  * \brief       Easy to use encoder initialization
4  *
5  * \author      Copyright (C) 1999-2006 Igor Pavlov
6  * \author      Copyright (C) 2008 Lasse Collin
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  */
18
19 #ifndef LZMA_H_INTERNAL
20 #       error Never include this file directly. Use <lzma.h> instead.
21 #endif
22
23
24 /**
25  * \brief       Compression level names for lzma_easy_* functions
26  *
27  * At the moment, all the compression levels support LZMA_SYNC_FLUSH.
28  * In future there may be levels that don't support LZMA_SYNC_FLUSH.
29  * However, the LZMA_SYNC_FLUSH support won't be removed from the
30  * existing compression levels.
31  *
32  * \note        If liblzma is built without encoder support, or with some
33  *              filters disabled, some of the compression levels may be
34  *              unsupported. In that case, the initialization functions
35  *              will return LZMA_HEADER_ERROR.
36  */
37 typedef enum {
38         LZMA_EASY_COPY,
39                 /**<
40                  * No compression; the data is just wrapped into .lzma
41                  * container.
42                  */
43
44         LZMA_EASY_LZMA_1,
45                 /**<
46                  * LZMA filter with fast compression (fast in terms of LZMA).
47                  * If you are interested in the exact options used, see
48                  * lzma_preset_lzma[0]. Note that the exact options may
49                  * change between liblzma versions.
50                  *
51                  * At the moment, the command line tool uses these settings
52                  * when `lzma -1' is used. In future, the command line tool
53                  * may default to some more complex way to determine the
54                  * settings used e.g. the type of files being compressed.
55                  *
56                  * LZMA_EASY_LZMA_2 is equivalent to lzma_preset_lzma[1]
57                  * and so on.
58                  */
59
60         LZMA_EASY_LZMA_2,
61         LZMA_EASY_LZMA_3,
62         LZMA_EASY_LZMA_4,
63         LZMA_EASY_LZMA_5,
64         LZMA_EASY_LZMA_6,
65         LZMA_EASY_LZMA_7,
66         LZMA_EASY_LZMA_8,
67         LZMA_EASY_LZMA_9,
68 } lzma_easy_level;
69
70
71 /**
72  * \brief       Default compression level
73  *
74  * Data Blocks contain the actual compressed data. It's not straightforward
75  * to recommend a default level, because in some cases keeping the resource
76  * usage relatively low is more important that getting the maximum
77  * compression ratio.
78  */
79 #define LZMA_EASY_DEFAULT LZMA_EASY_LZMA_7
80
81
82 /**
83  * \brief       Calculates rough memory requirements of a compression level
84  *
85  * This function is a wrapper for lzma_memory_usage(), which is declared
86  * in lzma/filter.h.
87  *
88  * \return      Approximate memory usage of the encoder with the given
89  *              compression level in mebibytes (value * 1024 * 1024 bytes).
90  *              On error (e.g. compression level is not supported),
91  *              UINT32_MAX is returned.
92  */
93 extern uint32_t lzma_easy_memory_usage(lzma_easy_level level);
94
95
96 /**
97  * \brief       Initializes .lzma Stream encoder
98  *
99  * This function is intended for those who just want to use the basic LZMA
100  * features (that is, most developers out there). Lots of assumptions are
101  * made, which are correct or at least good enough for most situations.
102  *
103  * \param       strm    Pointer to lzma_stream that is at least initialized
104  *                      with LZMA_STREAM_INIT.
105  * \param       level   Compression level to use. This selects a set of
106  *                      compression settings from a list of compression
107  *                      presets.
108  *
109  * \return      - LZMA_OK: Initialization succeeded. Use lzma_code() to
110  *                encode your data.
111  *              - LZMA_MEM_ERROR: Memory allocation failed. All memory
112  *                previously allocated for *strm is now freed.
113  *              - LZMA_HEADER_ERROR: The given compression level is not
114  *                supported by this build of liblzma.
115  *
116  * If initialization succeeds, use lzma_code() to do the actual encoding.
117  * Valid values for `action' (the second argument of lzma_code()) are
118  * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
119  * there may be compression levels that don't support LZMA_SYNC_FLUSH.
120  */
121 extern lzma_ret lzma_easy_encoder(lzma_stream *strm, lzma_easy_level level);