Skip to content

Commit

Permalink
Improve scene detection
Browse files Browse the repository at this point in the history
  • Loading branch information
master-of-zen committed Jun 2, 2021
1 parent 975def2 commit 183e56a
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 213 deletions.
11 changes: 4 additions & 7 deletions src/api/channel/by_gop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ impl<T: Pixel> SubGop<T> {
*/

// TODO: Make the detector logic fitting the model
struct SceneChange {
struct SceneChange<T: Pixel> {
frames: usize,
pyramid_size: usize,
processed: u64,
last_keyframe: u64,
detector: SceneChangeDetector,
detector: SceneChangeDetector<T>,
}

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

Expand All @@ -56,17 +56,14 @@ impl SceneChange {
CpuFeatureLevel::default(),
pyramid_size,
seq,
true,
);

Self { frames: 0, pyramid_size, processed: 0, last_keyframe: 0, detector }
}

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

let new_gop = self.detector.analyze_next_frame(
Expand Down
3 changes: 1 addition & 2 deletions src/api/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub(crate) struct ContextInner<T: Pixel> {
gop_output_frameno_start: BTreeMap<u64, u64>,
/// Maps `output_frameno` to `gop_input_frameno_start`.
pub(crate) gop_input_frameno_start: BTreeMap<u64, u64>,
keyframe_detector: SceneChangeDetector,
keyframe_detector: SceneChangeDetector<T>,
pub(crate) config: Arc<EncoderConfig>,
seq: Arc<Sequence>,
pub(crate) rc_state: RCState,
Expand Down Expand Up @@ -291,7 +291,6 @@ impl<T: Pixel> ContextInner<T> {
CpuFeatureLevel::default(),
lookahead_distance,
seq.clone(),
true,
),
config: Arc::new(*enc),
seq,
Expand Down
Loading

0 comments on commit 183e56a

Please sign in to comment.