| OLD | NEW |
| 1 /* Copyright 2013 Google Inc. All Rights Reserved. | 1 /* Copyright 2013 Google Inc. All Rights Reserved. |
| 2 | 2 |
| 3 Distributed under MIT license. | 3 Distributed under MIT license. |
| 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 // Functions for clustering similar histograms together. | 7 // Functions for clustering similar histograms together. |
| 8 | 8 |
| 9 #ifndef BROTLI_ENC_CLUSTER_H_ | 9 #ifndef BROTLI_ENC_CLUSTER_H_ |
| 10 #define BROTLI_ENC_CLUSTER_H_ | 10 #define BROTLI_ENC_CLUSTER_H_ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 size_t* num_pairs) { | 56 size_t* num_pairs) { |
| 57 if (idx1 == idx2) { | 57 if (idx1 == idx2) { |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 if (idx2 < idx1) { | 60 if (idx2 < idx1) { |
| 61 uint32_t t = idx2; | 61 uint32_t t = idx2; |
| 62 idx2 = idx1; | 62 idx2 = idx1; |
| 63 idx1 = t; | 63 idx1 = t; |
| 64 } | 64 } |
| 65 bool store_pair = false; | 65 bool store_pair = false; |
| 66 HistogramPair p; | 66 HistogramPair p = {}; |
| 67 p.idx1 = idx1; | 67 p.idx1 = idx1; |
| 68 p.idx2 = idx2; | 68 p.idx2 = idx2; |
| 69 p.cost_diff = 0.5 * ClusterCostDiff(cluster_size[idx1], cluster_size[idx2]); | 69 p.cost_diff = 0.5 * ClusterCostDiff(cluster_size[idx1], cluster_size[idx2]); |
| 70 p.cost_diff -= out[idx1].bit_cost_; | 70 p.cost_diff -= out[idx1].bit_cost_; |
| 71 p.cost_diff -= out[idx2].bit_cost_; | 71 p.cost_diff -= out[idx2].bit_cost_; |
| 72 | 72 |
| 73 if (out[idx1].total_count_ == 0) { | 73 if (out[idx1].total_count_ == 0) { |
| 74 p.cost_combo = out[idx2].bit_cost_; | 74 p.cost_combo = out[idx2].bit_cost_; |
| 75 store_pair = true; | 75 store_pair = true; |
| 76 } else if (out[idx2].total_count_ == 0) { | 76 } else if (out[idx2].total_count_ == 0) { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 // Convert the context map to a canonical form. | 322 // Convert the context map to a canonical form. |
| 323 size_t num_histograms = | 323 size_t num_histograms = |
| 324 HistogramReindex(&(*out)[0], &(*histogram_symbols)[0], in_size); | 324 HistogramReindex(&(*out)[0], &(*histogram_symbols)[0], in_size); |
| 325 out->resize(num_histograms); | 325 out->resize(num_histograms); |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace brotli | 328 } // namespace brotli |
| 329 | 329 |
| 330 #endif // BROTLI_ENC_CLUSTER_H_ | 330 #endif // BROTLI_ENC_CLUSTER_H_ |
| OLD | NEW |