-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- retyping of u128 to Timecode not everywhere fully clean - impl thread safe frame dropping strategy with comparing image hashes - keeping a linked list of `FrameEssences`
- Loading branch information
Showing
9 changed files
with
96 additions
and
82 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "t-rec" | ||
version = "0.7.3" | ||
version = "0.7.3-alpha.1" | ||
authors = ["Sven Assmann <[email protected]>"] | ||
edition = "2018" | ||
license = "GPL-3.0-only" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::collections::LinkedList; | ||
|
||
use crate::capture::{FrameDropStrategy, FrameEssence}; | ||
|
||
pub struct FrameComparator { | ||
last_frames: LinkedList<FrameEssence>, | ||
strategy: FrameDropStrategy, | ||
} | ||
|
||
impl FrameComparator { | ||
pub fn new(strategy: FrameDropStrategy) -> Self { | ||
Self { | ||
last_frames: LinkedList::new(), | ||
strategy, | ||
} | ||
} | ||
} | ||
|
||
impl FrameComparator { | ||
pub fn should_drop_frame(&mut self, frame_essence: FrameEssence) -> bool { | ||
match self.strategy { | ||
FrameDropStrategy::DoNotDropAny => false, | ||
FrameDropStrategy::DropIdenticalFrames => { | ||
if let Some(FrameEssence { when, what }) = self.last_frames.pop_back() { | ||
if frame_essence.when > when && what == frame_essence.what { | ||
// so the last frame and this one is the same... so let's drop it.. | ||
// but add the current frame | ||
self.last_frames.push_back(frame_essence); | ||
true | ||
} else { | ||
let previous_should_drop_frame = self.should_drop_frame(frame_essence); | ||
// restore the popped frame.. | ||
self.last_frames.push_back(FrameEssence { when, what }); | ||
|
||
previous_should_drop_frame | ||
} | ||
} else { | ||
self.last_frames.push_back(frame_essence); | ||
|
||
false | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use blockhash::{blockhash256, Blockhash256}; | ||
|
||
use crate::capture::{Frame, Timecode}; | ||
|
||
#[derive(Eq, PartialEq, Clone)] | ||
pub enum FrameDropStrategy { | ||
DoNotDropAny, | ||
DropIdenticalFrames, | ||
} | ||
|
||
#[derive(Eq, PartialOrd, PartialEq, Clone)] | ||
pub struct FrameEssence { | ||
pub(crate) when: Timecode, | ||
pub(crate) what: Blockhash256, | ||
} | ||
|
||
impl FrameEssence { | ||
pub fn new(frame: &Frame, timecode: &Timecode) -> Self { | ||
Self { | ||
when: timecode.clone(), | ||
what: blockhash256(frame), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
mod frame; | ||
mod frame_comparator; | ||
mod frame_essence; | ||
mod framerate; | ||
mod processor; | ||
mod timecode; | ||
|
||
pub use frame::*; | ||
pub use frame_comparator::*; | ||
pub use frame_essence::*; | ||
pub use framerate::*; | ||
pub use processor::*; | ||
pub use timecode::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters