Skip to content

Commit 3097ce2

Browse files
committed
Improve scene detection
1 parent a3badce commit 3097ce2

File tree

3 files changed

+295
-216
lines changed

3 files changed

+295
-216
lines changed

src/api/channel/by_gop.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ impl<T: Pixel> SubGop<T> {
3939
*/
4040

4141
// TODO: Make the detector logic fitting the model
42-
struct SceneChange {
42+
struct SceneChange<T: Pixel> {
4343
frames: usize,
4444
pyramid_size: usize,
4545
processed: u64,
4646
last_keyframe: u64,
47-
detector: SceneChangeDetector,
47+
detector: SceneChangeDetector<T>,
4848
}
4949

50-
impl SceneChange {
50+
impl<T: Pixel> SceneChange<T> {
5151
fn new(pyramid_size: usize, enc: &EncoderConfig) -> Self {
5252
let seq = Arc::new(Sequence::new(enc));
5353

@@ -56,17 +56,14 @@ impl SceneChange {
5656
CpuFeatureLevel::default(),
5757
pyramid_size,
5858
seq,
59-
true,
6059
);
6160

6261
Self { frames: 0, pyramid_size, processed: 0, last_keyframe: 0, detector }
6362
}
6463

6564
// Tell where to split the lookahead
6665
//
67-
fn split<T: Pixel>(
68-
&mut self, lookahead: &[Arc<Frame<T>>],
69-
) -> Option<(usize, bool)> {
66+
fn split(&mut self, lookahead: &[Arc<Frame<T>>]) -> Option<(usize, bool)> {
7067
self.processed += 1;
7168

7269
let new_gop = self.detector.analyze_next_frame(

src/api/internal.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pub(crate) struct ContextInner<T: Pixel> {
246246
gop_output_frameno_start: BTreeMap<u64, u64>,
247247
/// Maps `output_frameno` to `gop_input_frameno_start`.
248248
pub(crate) gop_input_frameno_start: BTreeMap<u64, u64>,
249-
keyframe_detector: SceneChangeDetector,
249+
keyframe_detector: SceneChangeDetector<T>,
250250
pub(crate) config: Arc<EncoderConfig>,
251251
seq: Arc<Sequence>,
252252
pub(crate) rc_state: RCState,
@@ -291,7 +291,6 @@ impl<T: Pixel> ContextInner<T> {
291291
CpuFeatureLevel::default(),
292292
lookahead_distance,
293293
seq.clone(),
294-
true,
295294
),
296295
config: Arc::new(*enc),
297296
seq,

0 commit comments

Comments
 (0)