]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/common/easy_common.c
Update the file format specification draft. The new one is
[icculus/xz.git] / src / liblzma / common / easy_common.c
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       easy_common.c
4 /// \brief      Shared stuff for easy encoder initialization functions
5 //
6 //  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
20 #include "easy_common.h"
21
22
23 extern bool
24 lzma_easy_set_filters(lzma_options_filter *filters, uint32_t level)
25 {
26         bool error = false;
27
28         if (level == 0) {
29                 filters[0].id = LZMA_VLI_VALUE_UNKNOWN;
30
31 #ifdef HAVE_FILTER_LZMA
32         } else if (level <= 9) {
33                 filters[0].id = LZMA_FILTER_LZMA;
34                 filters[0].options = (void *)(&lzma_preset_lzma[level - 1]);
35                 filters[1].id = LZMA_VLI_VALUE_UNKNOWN;
36 #endif
37
38         } else {
39                 error = true;
40         }
41
42         return error;
43 }
44
45
46 extern LZMA_API uint32_t
47 lzma_easy_memory_usage(lzma_easy_level level)
48 {
49         lzma_options_filter filters[8];
50         if (lzma_easy_set_filters(filters, level))
51                 return UINT32_MAX;
52
53         return lzma_memory_usage(filters, true);
54 }