diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /contrib/libs/brotli/enc/bit_cost.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/brotli/enc/bit_cost.h')
-rw-r--r-- | contrib/libs/brotli/enc/bit_cost.h | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/contrib/libs/brotli/enc/bit_cost.h b/contrib/libs/brotli/enc/bit_cost.h index 30324d38c7..6586469e62 100644 --- a/contrib/libs/brotli/enc/bit_cost.h +++ b/contrib/libs/brotli/enc/bit_cost.h @@ -1,63 +1,63 @@ /* Copyright 2013 Google Inc. All Rights Reserved. - + Distributed under MIT license. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ /* Functions to estimate the bit cost of Huffman trees. */ -#ifndef BROTLI_ENC_BIT_COST_H_ -#define BROTLI_ENC_BIT_COST_H_ - +#ifndef BROTLI_ENC_BIT_COST_H_ +#define BROTLI_ENC_BIT_COST_H_ + #include "../common/platform.h" #include <brotli/types.h> -#include "./fast_log.h" +#include "./fast_log.h" #include "./histogram.h" - + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - + static BROTLI_INLINE double ShannonEntropy( const uint32_t* population, size_t size, size_t* total) { size_t sum = 0; - double retval = 0; + double retval = 0; const uint32_t* population_end = population + size; size_t p; - if (size & 1) { - goto odd_number_of_elements_left; - } - while (population < population_end) { - p = *population++; - sum += p; + if (size & 1) { + goto odd_number_of_elements_left; + } + while (population < population_end) { + p = *population++; + sum += p; retval -= (double)p * FastLog2(p); - odd_number_of_elements_left: - p = *population++; - sum += p; + odd_number_of_elements_left: + p = *population++; + sum += p; retval -= (double)p * FastLog2(p); - } + } if (sum) retval += (double)sum * FastLog2(sum); - *total = sum; - return retval; -} - + *total = sum; + return retval; +} + static BROTLI_INLINE double BitsEntropy( const uint32_t* population, size_t size) { size_t sum; - double retval = ShannonEntropy(population, size, &sum); - if (retval < sum) { + double retval = ShannonEntropy(population, size, &sum); + if (retval < sum) { /* At least one bit per literal is needed. */ retval = (double)sum; - } - return retval; -} - + } + return retval; +} + BROTLI_INTERNAL double BrotliPopulationCostLiteral(const HistogramLiteral*); BROTLI_INTERNAL double BrotliPopulationCostCommand(const HistogramCommand*); BROTLI_INTERNAL double BrotliPopulationCostDistance(const HistogramDistance*); - + #if defined(__cplusplus) || defined(c_plusplus) } /* extern "C" */ #endif - + #endif /* BROTLI_ENC_BIT_COST_H_ */ |