Skip to content

Commit 8a44cdb

Browse files
authored
Tweak eval cmp key for more consistent results (#671)
This changes the evaluator to prefer a later image instead of an earlier one in the case of a tie. This gives more consistent results since the baseline is always added last. I also removed bit depth from the key since the uncompressed size should cover that. Fixes #649. (Mostly. I did discover another possible but very rare issue: if multiple colours tie for "most popular edge colour" in the luma sort, the sort may affect which one is actually picked and multiple runs may flip-flop back and forth)
1 parent 14b8b0e commit 8a44cdb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/evaluate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) struct Candidate {
2323
pub idat_data: Vec<u8>,
2424
pub filtered: Vec<u8>,
2525
pub filter: RowFilter,
26-
// first wins tie-breaker
26+
// For determining tie-breaker
2727
nth: usize,
2828
}
2929

@@ -32,9 +32,9 @@ impl Candidate {
3232
(
3333
self.idat_data.len() + self.image.key_chunks_size(),
3434
self.image.data.len(),
35-
self.image.ihdr.bit_depth,
3635
self.filter,
37-
self.nth,
36+
// Prefer the later image added (e.g. baseline, which is always added last)
37+
usize::MAX - self.nth,
3838
)
3939
}
4040
}

0 commit comments

Comments
 (0)