-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vapoursynth decoding support to allow for avoiding piping (#168)
- Loading branch information
1 parent
e6725c7
commit 574d0c1
Showing
8 changed files
with
373 additions
and
92 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/target | ||
**/*.rs.bk | ||
/.idea | ||
/.vscode |
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
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,40 @@ | ||
use std::io::Read; | ||
|
||
use rav1e::{Frame, Pixel}; | ||
|
||
#[cfg(feature = "vapoursynth")] | ||
use crate::vapoursynth::VapoursynthDecoder; | ||
use crate::y4m::VideoDetails; | ||
|
||
pub enum Decoder<R: Read> { | ||
Y4m(y4m::Decoder<R>), | ||
#[cfg(feature = "vapoursynth")] | ||
Vapoursynth(VapoursynthDecoder), | ||
} | ||
|
||
impl<R: Read> Decoder<R> { | ||
/// # Errors | ||
/// | ||
/// - If using a Vapoursynth script that contains an unsupported video format. | ||
pub fn get_video_details(&self) -> anyhow::Result<VideoDetails> { | ||
match self { | ||
Decoder::Y4m(dec) => Ok(crate::y4m::get_video_details(dec)), | ||
#[cfg(feature = "vapoursynth")] | ||
Decoder::Vapoursynth(dec) => dec.get_video_details(), | ||
} | ||
} | ||
|
||
/// # Errors | ||
/// | ||
/// - If a frame cannot be read. | ||
pub fn read_video_frame<T: Pixel>( | ||
&mut self, | ||
video_details: &VideoDetails, | ||
) -> anyhow::Result<Frame<T>> { | ||
match self { | ||
Decoder::Y4m(dec) => crate::y4m::read_video_frame::<R, T>(dec, video_details), | ||
#[cfg(feature = "vapoursynth")] | ||
Decoder::Vapoursynth(dec) => dec.read_video_frame::<T>(video_details), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.