pub struct SceneChangeDetector<T: Pixel> {Show 15 fields
threshold: f64,
speed_mode: SceneDetectionSpeed,
scale_func: Option<ScaleFunction<T>>,
downscaled_frame_buffer: Option<[Plane<T>; 2]>,
frame_me_stats_buffer: Option<Arc<RwLock<[FrameMEStats; 8]>>>,
lookahead_offset: usize,
deque_offset: usize,
score_deque: Vec<ScenecutResult>,
pixels: usize,
bit_depth: usize,
cpu_feature_level: CpuFeatureLevel,
encoder_config: EncoderConfig,
sequence: Arc<Sequence>,
pub(crate) intra_costs: BTreeMap<u64, Box<[u32]>>,
pub(crate) temp_plane: Option<Plane<T>>,
}
Expand description
Runs keyframe detection on frames from the lookahead queue.
Fields§
§threshold: f64
Minimum average difference between YUV deltas that will trigger a scene change.
speed_mode: SceneDetectionSpeed
Fast scene cut detection mode, uses simple SAD instead of encoder cost estimates.
scale_func: Option<ScaleFunction<T>>
Downscaling function for fast scene detection
downscaled_frame_buffer: Option<[Plane<T>; 2]>
Frame buffer for scaled frames
frame_me_stats_buffer: Option<Arc<RwLock<[FrameMEStats; 8]>>>
Buffer for FrameMEStats for cost scenecut
lookahead_offset: usize
Deque offset for current
deque_offset: usize
Start deque offset based on lookahead
score_deque: Vec<ScenecutResult>
Scenechange results for adaptive threshold
pixels: usize
Number of pixels in scaled frame for fast mode
bit_depth: usize
The bit depth of the video.
cpu_feature_level: CpuFeatureLevel
The CPU feature level to be used.
encoder_config: EncoderConfig
§sequence: Arc<Sequence>
§intra_costs: BTreeMap<u64, Box<[u32]>>
Calculated intra costs for each input frame. These are cached for reuse later in rav1e.
temp_plane: Option<Plane<T>>
Temporary buffer used by estimate_intra_costs.
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: u64,
) -> ScenecutResult
pub(super) fn cost_scenecut( &mut self, frame1: Arc<Frame<T>>, frame2: Arc<Frame<T>>, input_frameno: u64, ) -> 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>
pub fn new( encoder_config: EncoderConfig, cpu_feature_level: CpuFeatureLevel, lookahead_distance: usize, sequence: Arc<Sequence>, ) -> Self
Sourcepub fn analyze_next_frame(
&mut self,
frame_set: &[&Arc<Frame<T>>],
input_frameno: u64,
previous_keyframe: u64,
) -> bool
pub fn analyze_next_frame( &mut self, frame_set: &[&Arc<Frame<T>>], input_frameno: u64, previous_keyframe: u64, ) -> 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: u64) -> Option<bool>
fn initialize_score_deque( &mut self, frame_set: &[&Arc<Frame<T>>], input_frameno: u64, init_len: usize, )
Sourcefn run_comparison(
&mut self,
frame1: Arc<Frame<T>>,
frame2: Arc<Frame<T>>,
input_frameno: u64,
)
fn run_comparison( &mut self, frame1: Arc<Frame<T>>, frame2: Arc<Frame<T>>, input_frameno: u64, )
Runs scene change comparison beetween 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> 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