Struct SceneChangeDetector

Source
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>

Source

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.

Source

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>

Source

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>

Source

pub fn new( encoder_config: EncoderConfig, cpu_feature_level: CpuFeatureLevel, lookahead_distance: usize, sequence: Arc<Sequence>, ) -> Self

Source

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.

Source

fn handle_min_max_intervals(&mut self, distance: u64) -> Option<bool>

Source

fn initialize_score_deque( &mut self, frame_set: &[&Arc<Frame<T>>], input_frameno: u64, init_len: usize, )

Source

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

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.