mirror of https://git.tukaani.org/xz.git
xz: Edit comments and coding style
This commit is contained in:
parent
fe4d8b0c80
commit
e4780244a1
|
@ -144,6 +144,7 @@ coder_add_filter(lzma_vli id, void *options)
|
||||||
|
|
||||||
filters[0][filters_count].id = id;
|
filters[0][filters_count].id = id;
|
||||||
filters[0][filters_count].options = options;
|
filters[0][filters_count].options = options;
|
||||||
|
|
||||||
// Terminate the filter chain with LZMA_VLI_UNKNOWN to simplify
|
// Terminate the filter chain with LZMA_VLI_UNKNOWN to simplify
|
||||||
// implementation of forget_filter_chain().
|
// implementation of forget_filter_chain().
|
||||||
filters[0][++filters_count].id = LZMA_VLI_UNKNOWN;
|
filters[0][++filters_count].id = LZMA_VLI_UNKNOWN;
|
||||||
|
@ -246,16 +247,16 @@ validate_block_list_filter(const uint32_t filter_num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sets the memory usage for each filter chain. It will return the maximum
|
// Calculate the memory usage of each filter chain.
|
||||||
// memory usage of all of the filter chains.
|
// Return the maximum memory usage of all of the filter chains.
|
||||||
static uint64_t
|
static uint64_t
|
||||||
filters_memusage_max(const lzma_mt *mt, bool encode)
|
filters_memusage_max(const lzma_mt *mt, bool encode)
|
||||||
{
|
{
|
||||||
uint64_t max_memusage = 0;
|
uint64_t max_memusage = 0;
|
||||||
|
|
||||||
#ifdef MYTHREAD_ENABLED
|
#ifdef MYTHREAD_ENABLED
|
||||||
// Copy multithreaded options to a temporary struct since the
|
// Copy multithreading options to a temporary struct since the
|
||||||
// filters member needs to be changed
|
// "filters" member needs to be changed.
|
||||||
lzma_mt mt_local;
|
lzma_mt mt_local;
|
||||||
if (mt != NULL)
|
if (mt != NULL)
|
||||||
mt_local = *mt;
|
mt_local = *mt;
|
||||||
|
@ -273,15 +274,12 @@ filters_memusage_max(const lzma_mt *mt, bool encode)
|
||||||
mt_local.filters = filters[i];
|
mt_local.filters = filters[i];
|
||||||
memusage = lzma_stream_encoder_mt_memusage(&mt_local);
|
memusage = lzma_stream_encoder_mt_memusage(&mt_local);
|
||||||
filter_memusages[i] = memusage;
|
filter_memusages[i] = memusage;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (encode) {
|
if (encode) {
|
||||||
memusage = lzma_raw_encoder_memusage(filters[i]);
|
memusage = lzma_raw_encoder_memusage(filters[i]);
|
||||||
filter_memusages[i] = memusage;
|
filter_memusages[i] = memusage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DECODERS
|
#ifdef HAVE_DECODERS
|
||||||
else {
|
else {
|
||||||
memusage = lzma_raw_decoder_memusage(filters[i]);
|
memusage = lzma_raw_decoder_memusage(filters[i]);
|
||||||
|
@ -294,9 +292,9 @@ filters_memusage_max(const lzma_mt *mt, bool encode)
|
||||||
|
|
||||||
return max_memusage;
|
return max_memusage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
coder_set_compression_settings(void)
|
coder_set_compression_settings(void)
|
||||||
{
|
{
|
||||||
|
@ -335,7 +333,8 @@ coder_set_compression_settings(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(filters_ref_mask != 0);
|
assert(filters_ref_mask != 0);
|
||||||
// Note: The filters that were initialized but not used do
|
|
||||||
|
// NOTE: The filters that were initialized but not used do
|
||||||
// not free their options and do not have the filter
|
// not free their options and do not have the filter
|
||||||
// IDs set to LZMA_VLI_UNKNOWN. Filter chains are not
|
// IDs set to LZMA_VLI_UNKNOWN. Filter chains are not
|
||||||
// freed outside of debug mode and the default filter
|
// freed outside of debug mode and the default filter
|
||||||
|
@ -465,6 +464,7 @@ coder_set_compression_settings(void)
|
||||||
mt_options.threads = hardware_threads_get();
|
mt_options.threads = hardware_threads_get();
|
||||||
|
|
||||||
uint64_t block_size = opt_block_size;
|
uint64_t block_size = opt_block_size;
|
||||||
|
|
||||||
// If opt_block_size is not set, find the maximum
|
// If opt_block_size is not set, find the maximum
|
||||||
// recommended Block size based on the filter chains
|
// recommended Block size based on the filter chains
|
||||||
if (block_size == 0) {
|
if (block_size == 0) {
|
||||||
|
@ -539,7 +539,7 @@ coder_set_compression_settings(void)
|
||||||
filters_memusage_max(NULL, false);
|
filters_memusage_max(NULL, false);
|
||||||
#else
|
#else
|
||||||
// If encoders are not enabled, then --block-list is never
|
// If encoders are not enabled, then --block-list is never
|
||||||
// usable, so the other filter chains 1-9 can never be used.
|
// usable and the filter chains 1-9 are never used.
|
||||||
// So there is no need to find the maximum decoder memory
|
// So there is no need to find the maximum decoder memory
|
||||||
// required in this case.
|
// required in this case.
|
||||||
const uint64_t decmem = lzma_raw_decoder_memusage(filters[0]);
|
const uint64_t decmem = lzma_raw_decoder_memusage(filters[0]);
|
||||||
|
@ -736,8 +736,7 @@ coder_set_compression_settings(void)
|
||||||
if (filt_mem_usage < memory_limit) {
|
if (filt_mem_usage < memory_limit) {
|
||||||
r->reduce_dict_size = false;
|
r->reduce_dict_size = false;
|
||||||
count--;
|
count--;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
opt->dict_size -= UINT32_C(1) << 20;
|
opt->dict_size -= UINT32_C(1) << 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue