Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
master-of-zen committed May 26, 2021
1 parent 49dbf1d commit 3984fa8
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/scenechange/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ impl<T: Pixel> SceneChangeDetector<T> {
return false;
}

// Decrease deque offset if there is no more new frames
if self.deque_offset > frame_set.len() + 1 && self.lookahead_offset > 0 {
self.deque_offset = self.deque_offset - 1;
}

// Initially fill score deque with forward frames
// ititiallization is different depending on frame set length
if self.deque_offset > 0
Expand All @@ -164,13 +159,16 @@ impl<T: Pixel> SceneChangeDetector<T> {
self.deque_offset = frame_set.len() - 2;
}
// Running single frame comparison and adding it to deque
// Decrease deque offset if there is no new frames
if frame_set.len() > self.deque_offset + 1 {
self.run_comparison(
frame_set[self.deque_offset].clone(),
frame_set[self.deque_offset + 1].clone(),
input_frameno,
previous_keyframe,
);
} else {
self.deque_offset -= 1;
}

// Adaptive scenecut check
Expand Down Expand Up @@ -237,12 +235,6 @@ impl<T: Pixel> SceneChangeDetector<T> {
let mut cloned_deque = self.score_deque.to_vec();
cloned_deque.remove(self.deque_offset);

let max_of_deque: f64 = cloned_deque
.iter()
.cloned()
.map(|(b, _)| b)
.fold(-1. / 0. /* -inf */, f64::max);

let scene_score = self.score_deque[self.deque_offset].0;
let scene_threshold = self.score_deque[self.deque_offset].1;

Expand All @@ -261,6 +253,7 @@ impl<T: Pixel> SceneChangeDetector<T> {
if !back_over_tr.is_empty()
&& forward_over_tr.is_empty()
&& back_deque.len() > 1
&& back_over_tr.len() > 1
{
return true;
}
Expand All @@ -274,14 +267,13 @@ impl<T: Pixel> SceneChangeDetector<T> {
{
return true;
}

if !back_over_tr.is_empty() || !forward_over_tr.is_empty() {
return false;
}
}

let threshold = if self.fast_mode {
self.threshold as f64 + max_of_deque
} else {
scene_threshold
};
scene_score >= threshold
scene_score >= scene_threshold
}

/// The fast algorithm detects fast cuts using a raw difference
Expand Down

0 comments on commit 3984fa8

Please sign in to comment.