From 8bc92013d0f687d4ea4fb2ddf0da38ac1df8c354 Mon Sep 17 00:00:00 2001 From: Luca Barbato <lu_zero@gentoo.org> Date: Sat, 15 Sep 2018 02:03:20 +0200 Subject: [PATCH] Use for_each for the skip/not skip inner loop rdo And use a conditional slice outside the chroma loop. --- src/rdo.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/rdo.rs b/src/rdo.rs index 469db575..c3e5a0e8 100755 --- a/src/rdo.rs +++ b/src/rdo.rs @@ -332,15 +332,19 @@ pub fn rdo_mode_decision( seq, fi, fs, cw, bsize, bo, luma_mode, ref_frame, mv, false, ); + let all_skips = [false, true]; + + // Don't skip when using intra modes + let skips = if luma_mode_is_intra { + &all_skips[..1] + } else { + &all_skips[..] + }; + // Find the best chroma prediction mode for the current luma prediction mode for &chroma_mode in &mode_set_chroma { - for &skip in &[false, true] { - // Don't skip when using intra modes - if skip && luma_mode_is_intra { - continue; - } - - let mut wr: &mut dyn Writer = &mut WriterCounter::new(); + skips.iter().for_each(|&skip| { + let wr: &mut dyn Writer = &mut WriterCounter::new(); let tell = wr.tell_frac(); encode_block_a(seq, cw, wr, bsize, bo, skip); @@ -390,7 +394,7 @@ pub fn rdo_mode_decision( } cw.rollback(&cw_checkpoint); - } + }); } }); -- GitLab