pub struct SceneChangeDetector<T: Pixel> {Show 18 fields
scene_detection_mode: SceneDetectionSpeed,
lookahead_offset: usize,
min_key_frame_interval: usize,
max_key_frame_interval: usize,
cpu_feature_level: CpuFeatureLevel,
threshold: f64,
resolution: (usize, usize),
bit_depth: usize,
frame_rate: Rational32,
chroma_sampling: ChromaSampling,
scaled_pixels: usize,
scale_func: Option<ScaleFunction<T>>,
deque_offset: usize,
downscaled_frame_buffer: Option<[Plane<T>; 2]>,
score_deque: Vec<ScenecutResult>,
temp_plane: Option<Plane<T>>,
frame_me_stats_buffer: Option<Arc<RwLock<[FrameMEStats; 8]>>>,
pub intra_costs: Option<BTreeMap<usize, Box<[u32]>>>,
}Expand description
Runs keyframe detection on frames from the lookahead queue.
This struct is intended for advanced users who need the ability to analyze
a small subset of frames at a time, for example in a streaming fashion.
Most users will prefer to use new_detector and detect_scene_changes
at the top level of this crate.
Fields§
§scene_detection_mode: SceneDetectionSpeedScenecut detection mode
lookahead_offset: usizeDeque offset for current
min_key_frame_interval: usizeMinimum number of frames between two scenecuts
max_key_frame_interval: usizeMaximum number of frames between two scenecuts
cpu_feature_level: CpuFeatureLevelThe CPU feature level to be used.
threshold: f64Minimum average difference between YUV deltas that will trigger a scene change.
resolution: (usize, usize)Width and height of the unscaled frame
bit_depth: usizeThe bit depth of the video.
frame_rate: Rational32The frame rate of the video.
chroma_sampling: ChromaSamplingThe chroma subsampling of the video.
scaled_pixels: usizeNumber of pixels in scaled frame for fast mode
scale_func: Option<ScaleFunction<T>>Downscaling function for fast scene detection
deque_offset: usizeStart deque offset based on lookahead
downscaled_frame_buffer: Option<[Plane<T>; 2]>Frame buffer for scaled frames
score_deque: Vec<ScenecutResult>Scenechange results for adaptive threshold
temp_plane: Option<Plane<T>>Temporary buffer used by estimate_intra_costs.
We store it on the struct so we only need to allocate it once.
frame_me_stats_buffer: Option<Arc<RwLock<[FrameMEStats; 8]>>>Buffer for FrameMEStats for cost scenecut
intra_costs: Option<BTreeMap<usize, Box<[u32]>>>Calculated intra costs for each input frame.
These can be cached for reuse by advanced API users.
Caching will occur if this is not None.
Implementations§
Source§impl<T: Pixel> SceneChangeDetector<T>
impl<T: Pixel> SceneChangeDetector<T>
Sourcepub(super) fn fast_scenecut(
&mut self,
frame1: Arc<Frame<T>>,
frame2: Arc<Frame<T>>,
) -> ScenecutResult
pub(super) fn fast_scenecut( &mut self, frame1: Arc<Frame<T>>, frame2: Arc<Frame<T>>, ) -> ScenecutResult
The fast algorithm detects fast cuts using a raw difference in pixel values between the scaled frames.
Sourcefn delta_in_planes(&self, plane1: &Plane<T>, plane2: &Plane<T>) -> f64
fn delta_in_planes(&self, plane1: &Plane<T>, plane2: &Plane<T>) -> f64
Calculates the average sum of absolute difference (SAD) per pixel between 2 planes
Source§impl<T: Pixel> SceneChangeDetector<T>
impl<T: Pixel> SceneChangeDetector<T>
Sourcepub(super) fn cost_scenecut(
&mut self,
frame1: Arc<Frame<T>>,
frame2: Arc<Frame<T>>,
input_frameno: usize,
) -> ScenecutResult
pub(super) fn cost_scenecut( &mut self, frame1: Arc<Frame<T>>, frame2: Arc<Frame<T>>, input_frameno: usize, ) -> ScenecutResult
Run a comparison between two frames to determine if they qualify for a scenecut.
We gather both intra and inter costs for the frames, as well as an importance-block-based difference, and use all three metrics.
Source§impl<T: Pixel> SceneChangeDetector<T>
impl<T: Pixel> SceneChangeDetector<T>
Sourcepub fn new(
resolution: (usize, usize),
bit_depth: usize,
frame_rate: Rational32,
chroma_sampling: ChromaSampling,
lookahead_distance: usize,
scene_detection_mode: SceneDetectionSpeed,
min_key_frame_interval: usize,
max_key_frame_interval: usize,
cpu_feature_level: CpuFeatureLevel,
) -> Self
pub fn new( resolution: (usize, usize), bit_depth: usize, frame_rate: Rational32, chroma_sampling: ChromaSampling, lookahead_distance: usize, scene_detection_mode: SceneDetectionSpeed, min_key_frame_interval: usize, max_key_frame_interval: usize, cpu_feature_level: CpuFeatureLevel, ) -> Self
Creates a new instance of the SceneChangeDetector.
Sourcepub fn enable_cache(&mut self)
pub fn enable_cache(&mut self)
Enables caching of intra costs. For advanced API users.
Sourcepub fn analyze_next_frame(
&mut self,
frame_set: &[&Arc<Frame<T>>],
input_frameno: usize,
previous_keyframe: usize,
) -> bool
pub fn analyze_next_frame( &mut self, frame_set: &[&Arc<Frame<T>>], input_frameno: usize, previous_keyframe: usize, ) -> bool
Runs keyframe detection on the next frame in the lookahead queue.
This function requires that a subset of input frames
is passed to it in order, and that keyframes is only
updated from this method. input_frameno should correspond
to the second frame in frame_set.
This will gracefully handle the first frame in the video as well.
fn handle_min_max_intervals(&mut self, distance: usize) -> Option<bool>
fn initialize_score_deque( &mut self, frame_set: &[&Arc<Frame<T>>], input_frameno: usize, init_len: usize, )
Sourcefn run_comparison(
&mut self,
frame1: Arc<Frame<T>>,
frame2: Arc<Frame<T>>,
input_frameno: usize,
)
fn run_comparison( &mut self, frame1: Arc<Frame<T>>, frame2: Arc<Frame<T>>, input_frameno: usize, )
Runs scene change comparison between 2 given frames Insert result to start of score deque
Sourcefn adaptive_scenecut(&mut self) -> (bool, ScenecutResult)
fn adaptive_scenecut(&mut self) -> (bool, ScenecutResult)
Compares current scene score to adapted threshold based on previous scores
Value of current frame is offset by lookahead, if lookahead >=5
Returns true if current scene score is higher than adapted threshold
Auto Trait Implementations§
impl<T> Freeze for SceneChangeDetector<T>
impl<T> RefUnwindSafe for SceneChangeDetector<T>where
T: RefUnwindSafe,
impl<T> Send for SceneChangeDetector<T>
impl<T> Sync for SceneChangeDetector<T>
impl<T> Unpin for SceneChangeDetector<T>where
T: Unpin,
impl<T> UnsafeUnpin for SceneChangeDetector<T>
impl<T> UnwindSafe for SceneChangeDetector<T>where
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more