Skip to content

Commit

Permalink
Another try
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Nov 28, 2019
1 parent 4327252 commit a0e3e46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 47 deletions.
44 changes: 1 addition & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions av_metrics/src/video/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,20 @@ pub enum ParallelMethod {

macro_rules! process_video {
($self:ident, $decoder1:ident, $decoder2:ident, $frame_limit:ident, $type:ident, $ret:ident) => {
$ret = iter::from_fn(|| $decoder1.read_video_frame::<$type>().ok())
.zip(iter::from_fn(|| $decoder2.read_video_frame::<$type>().ok()))
.take($frame_limit.unwrap_or(std::usize::MAX))
$ret = (0..$frame_limit.unwrap_or(std::usize::MAX))
.map(|_| {
(
$decoder1.read_video_frame::<$type>().ok(),
$decoder2.read_video_frame::<$type>().ok(),
)
})
.take_while(|(frame1, frame2)| frame1.is_some() && frame2.is_some())
.par_bridge()
.try_fold(
|| vec![],
|mut acc, (frame1, frame2)| {
|mut acc, (f1, f2)| {
let frame1 = f1.unwrap();
let frame2 = f2.unwrap();
$self
.process_frame(&frame1, &frame2)
.map(|(metrics, cweight)| {
Expand Down

0 comments on commit a0e3e46

Please sign in to comment.