Skip to content

Commit 774b0d1

Browse files
authored
Add a enable_early_exit flag under fi (#885)
Its value is set as true by default.
1 parent f4c00d2 commit 774b0d1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/encoder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ pub struct FrameInvariants {
569569
pub me_range_scale: u8,
570570
pub use_tx_domain_distortion: bool,
571571
pub inter_cfg: Option<InterPropsConfig>,
572+
pub enable_early_exit: bool,
572573
}
573574

574575
impl FrameInvariants {
@@ -642,6 +643,7 @@ impl FrameInvariants {
642643
me_range_scale: 1,
643644
use_tx_domain_distortion: use_tx_domain_distortion,
644645
inter_cfg: None,
646+
enable_early_exit: true,
645647
}
646648
}
647649

@@ -2422,7 +2424,7 @@ fn encode_partition_bottomup(
24222424

24232425
if cost != std::f64::MAX {
24242426
rd_cost += cost;
2425-
if rd_cost >= best_rd || rd_cost >= ref_rd_cost {
2427+
if fi.enable_early_exit && (rd_cost >= best_rd || rd_cost >= ref_rd_cost) {
24262428
assert!(cost != std::f64::MAX);
24272429
early_exit = true;
24282430
if partition == PartitionType::PARTITION_SPLIT { break; }

src/rdo.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ pub fn rdo_partition_decision(
970970
let mut best_partition = cached_block.part_type;
971971
let mut best_rd = cached_block.rd_cost;
972972
let mut best_pred_modes = cached_block.part_modes.clone();
973-
let mut early_exit;
974973

975974
let cw_checkpoint = cw.checkpoint();
976975
let w_pre_checkpoint = w_pre_cdef.checkpoint();
@@ -981,9 +980,9 @@ pub fn rdo_partition_decision(
981980
if partition == cached_block.part_type {
982981
continue;
983982
}
984-
early_exit = false;
985983
let mut cost: f64 = 0.0;
986984
let mut child_modes = std::vec::Vec::new();
985+
let mut early_exit = false;
987986

988987
match partition {
989988
PartitionType::PARTITION_NONE => {
@@ -1050,7 +1049,7 @@ pub fn rdo_partition_decision(
10501049

10511050
rd_cost_sum += mode_decision.rd_cost;
10521051

1053-
if rd_cost_sum > best_rd {
1052+
if fi.enable_early_exit && rd_cost_sum > best_rd {
10541053
early_exit = true;
10551054
break;
10561055
}

0 commit comments

Comments
 (0)