Skip to content

Commit 37d403b

Browse files
authored
Merge pull request #214 from nyurik/cifix
Fix CI: avoid breaking semver
2 parents 85196be + e7e2b26 commit 37d403b

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/enc/bit_cost.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use alloc::SliceWrapperMut;
2-
32
use core::cmp::{max, min};
43

54
use super::super::alloc::SliceWrapper;
@@ -8,11 +7,17 @@ use super::util::{FastLog2, FastLog2u16};
87
use super::vectorization::Mem256i;
98
use crate::enc::floatX;
109

11-
1210
const BROTLI_REPEAT_ZERO_CODE_LENGTH: usize = 17;
1311
const BROTLI_CODE_LENGTH_CODES: usize = BROTLI_REPEAT_ZERO_CODE_LENGTH + 1;
1412

15-
pub fn ShannonEntropy(mut population: &[u32], size: usize) -> (floatX, usize) {
13+
#[deprecated(note = "use shannon_entropy instead")]
14+
pub fn ShannonEntropy(population: &[u32], size: usize, total: &mut usize) -> floatX {
15+
let (result, tot) = shannon_entropy(population, size);
16+
*total = tot;
17+
result
18+
}
19+
20+
pub(crate) fn shannon_entropy(mut population: &[u32], size: usize) -> (floatX, usize) {
1621
let mut sum: usize = 0;
1722
let mut retval: floatX = 0.0;
1823

@@ -36,7 +41,7 @@ pub fn ShannonEntropy(mut population: &[u32], size: usize) -> (floatX, usize) {
3641

3742
#[inline(always)]
3843
pub fn BitsEntropy(population: &[u32], size: usize) -> floatX {
39-
let (mut retval, sum) = ShannonEntropy(population, size);
44+
let (mut retval, sum) = shannon_entropy(population, size);
4045
if retval < sum as floatX {
4146
retval = sum as floatX;
4247
}

src/enc/encode.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::backward_references::{
1010
H6Sub, HQ5Sub, HQ7Sub, HowPrepared, StoreLookaheadThenStore, Struct1, UnionHasher, H9,
1111
H9_BLOCK_BITS, H9_BLOCK_SIZE, H9_BUCKET_BITS, H9_NUM_LAST_DISTANCES_TO_CHECK,
1212
};
13-
use super::bit_cost::{BitsEntropy, ShannonEntropy};
13+
use super::bit_cost::{shannon_entropy, BitsEntropy};
1414
use super::brotli_bit_stream::{
1515
store_meta_block, store_meta_block_fast, store_meta_block_trivial,
1616
store_uncompressed_meta_block, BrotliWriteEmptyLastMetaBlock, BrotliWriteMetadataMetaBlock,
@@ -1741,12 +1741,12 @@ fn ChooseContextMap(
17411741
}
17421742
i = i.wrapping_add(1);
17431743
}
1744-
entropy[1] = ShannonEntropy(&monogram_histo[..], 3).0;
1744+
entropy[1] = shannon_entropy(&monogram_histo[..], 3).0;
17451745
entropy[2] =
1746-
ShannonEntropy(&two_prefix_histo[..], 3).0 + ShannonEntropy(&two_prefix_histo[3..], 3).0;
1746+
shannon_entropy(&two_prefix_histo[..], 3).0 + shannon_entropy(&two_prefix_histo[3..], 3).0;
17471747
entropy[3] = 0.0;
17481748
for i in 0usize..3usize {
1749-
entropy[3] += ShannonEntropy(&bigram_histo[(3usize).wrapping_mul(i)..], 3).0;
1749+
entropy[3] += shannon_entropy(&bigram_histo[(3usize).wrapping_mul(i)..], 3).0;
17501750
}
17511751
let total: usize = monogram_histo[0]
17521752
.wrapping_add(monogram_histo[1])
@@ -1834,11 +1834,11 @@ fn ShouldUseComplexStaticContextMap(
18341834
}
18351835
start_pos += 4096;
18361836
}
1837-
entropy[1] = ShannonEntropy(&combined_histo[..], 32).0;
1837+
entropy[1] = shannon_entropy(&combined_histo[..], 32).0;
18381838
entropy[2] = 0.0;
18391839
for i in 0..13 {
18401840
assert!(i < 13);
1841-
entropy[2] += ShannonEntropy(&context_histo[i][..], 32).0;
1841+
entropy[2] += shannon_entropy(&context_histo[i][..], 32).0;
18421842
}
18431843
entropy[0] = 1.0 / (total as floatX);
18441844
entropy[1] *= entropy[0];

0 commit comments

Comments
 (0)