From 8a44cdbc848a225e4f7aa19a54e4cc0f7f21485e Mon Sep 17 00:00:00 2001 From: andrews05 Date: Thu, 30 Jan 2025 07:56:27 +1300 Subject: [PATCH] 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) --- src/evaluate.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/evaluate.rs b/src/evaluate.rs index b3801fac..dd60aee6 100644 --- a/src/evaluate.rs +++ b/src/evaluate.rs @@ -23,7 +23,7 @@ pub(crate) struct Candidate { pub idat_data: Vec, pub filtered: Vec, pub filter: RowFilter, - // first wins tie-breaker + // For determining tie-breaker nth: usize, } @@ -32,9 +32,9 @@ impl Candidate { ( self.idat_data.len() + self.image.key_chunks_size(), self.image.data.len(), - self.image.ihdr.bit_depth, self.filter, - self.nth, + // Prefer the later image added (e.g. baseline, which is always added last) + usize::MAX - self.nth, ) } }