1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Finds out the minimal reasonable chunk size for a filter chain
6 // Copyright (C) 2007 Lasse Collin
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.
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.
18 ///////////////////////////////////////////////////////////////////////////////
24 * \brief Finds out the minimal reasonable chunk size for a filter chain
26 * This function helps determining the Uncompressed Sizes of the Blocks when
27 * doing multi-threaded encoding.
29 * When compressing a large file on a system having multiple CPUs or CPU
30 * cores, the file can be splitted in smaller chunks, that are compressed
31 * independently into separate Blocks in the same .lzma Stream.
33 * \return Minimum reasonable Uncompressed Size of a Block. The
34 * recommended minimum Uncompressed Size is between this value
35 * and the value times two.
37 Zero if the Uncompressed Sizes of Blocks don't matter
39 extern LZMA_API size_t
40 lzma_chunk_size(const lzma_options_filter *filters)
42 while (filters->id != LZMA_VLI_VALUE_UNKNOWN) {
43 switch (filters->id) {
44 // TODO LZMA_FILTER_SPARSE
46 case LZMA_FILTER_COPY:
47 case LZMA_FILTER_SUBBLOCK:
49 case LZMA_FILTER_POWERPC:
50 case LZMA_FILTER_IA64:
52 case LZMA_FILTER_ARMTHUMB:
53 case LZMA_FILTER_SPARC:
54 // These are very fast, thus there is no point in
55 // splitting the data in smaller blocks.
58 case LZMA_FILTER_LZMA:
59 // The block sizes of the possible next filters in
60 // the chain are irrelevant after the LZMA filter.
61 return ((lzma_options_lzma *)(filters->options))
72 // Indicate that splitting would be useless.