You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.0 KiB
96 lines
3.0 KiB
5 years ago
|
From 13771f767a4cb02ddd91aa35f8391b970178a6cb Mon Sep 17 00:00:00 2001
|
||
|
From: Luca Barbato <lu_zero@gentoo.org>
|
||
|
Date: Wed, 27 May 2020 17:35:58 +0200
|
||
|
Subject: [PATCH 2/2] Avoid some indirection now that we can directly store the
|
||
|
Writer/Reader in y4m
|
||
|
|
||
|
(cherry picked from commit d9ee06aae99b2a6c6dcb9c88da78b931610981da)
|
||
|
---
|
||
|
src/bin/rav1e.rs | 31 +++++++++++++++----------------
|
||
|
1 file changed, 15 insertions(+), 16 deletions(-)
|
||
|
|
||
|
diff --git a/src/bin/rav1e.rs b/src/bin/rav1e.rs
|
||
|
index 675171f64e27..3ae2636bc87f 100644
|
||
|
--- a/src/bin/rav1e.rs
|
||
|
+++ b/src/bin/rav1e.rs
|
||
|
@@ -196,7 +196,7 @@ fn process_frame<T: Pixel, D: Decoder>(
|
||
|
|
||
|
fn do_encode<T: Pixel, D: Decoder>(
|
||
|
cfg: Config, verbose: bool, mut progress: ProgressInfo,
|
||
|
- output: &mut dyn Muxer, source: &mut Source<D>,
|
||
|
+ output: &mut dyn Muxer, mut source: Source<D>,
|
||
|
pass1file_name: Option<&String>, pass2file_name: Option<&String>,
|
||
|
mut y4m_enc: Option<y4m::Encoder<Box<dyn Write>>>,
|
||
|
) -> Result<(), CliError> {
|
||
|
@@ -223,7 +223,7 @@ fn do_encode<T: Pixel, D: Decoder>(
|
||
|
while let Some(frame_info) = process_frame(
|
||
|
&mut ctx,
|
||
|
&mut *output,
|
||
|
- source,
|
||
|
+ &mut source,
|
||
|
pass1file.as_mut(),
|
||
|
pass2file.as_mut(),
|
||
|
&mut buffer,
|
||
|
@@ -348,15 +348,14 @@ fn run() -> Result<(), error::CliError> {
|
||
|
.saturating_mul(2304)
|
||
|
.saturating_add(1024),
|
||
|
};
|
||
|
- let mut y4m_dec =
|
||
|
- match y4m::Decoder::new_with_limits(&mut cli.io.input, limit) {
|
||
|
- Err(_) => {
|
||
|
- return Err(CliError::new("Could not input video. Is it a y4m file?"))
|
||
|
- }
|
||
|
- Ok(d) => d,
|
||
|
- };
|
||
|
+ let mut y4m_dec = match y4m::Decoder::new_with_limits(cli.io.input, limit) {
|
||
|
+ Err(_) => {
|
||
|
+ return Err(CliError::new("Could not input video. Is it a y4m file?"))
|
||
|
+ }
|
||
|
+ Ok(d) => d,
|
||
|
+ };
|
||
|
let video_info = y4m_dec.get_video_details();
|
||
|
- let y4m_enc = match cli.io.rec.as_mut() {
|
||
|
+ let y4m_enc = match cli.io.rec {
|
||
|
Some(rec) => Some(
|
||
|
y4m::encode(
|
||
|
video_info.width,
|
||
|
@@ -462,29 +461,29 @@ fn run() -> Result<(), error::CliError> {
|
||
|
};
|
||
|
|
||
|
#[cfg(all(unix, feature = "signal-hook"))]
|
||
|
- let mut source =
|
||
|
+ let source =
|
||
|
Source { limit: cli.limit, input: y4m_dec, count: 0, exit_requested };
|
||
|
#[cfg(not(all(unix, feature = "signal-hook")))]
|
||
|
- let mut source = Source { limit: cli.limit, input: y4m_dec, count: 0 };
|
||
|
+ let source = Source { limit: cli.limit, input: y4m_dec, count: 0 };
|
||
|
|
||
|
if video_info.bit_depth == 8 {
|
||
|
- do_encode::<u8, y4m::Decoder<'_, Box<dyn Read>>>(
|
||
|
+ do_encode::<u8, y4m::Decoder<Box<dyn Read>>>(
|
||
|
cfg,
|
||
|
cli.verbose,
|
||
|
progress,
|
||
|
&mut *cli.io.output,
|
||
|
- &mut source,
|
||
|
+ source,
|
||
|
cli.pass1file_name.as_ref(),
|
||
|
cli.pass2file_name.as_ref(),
|
||
|
y4m_enc,
|
||
|
)?
|
||
|
} else {
|
||
|
- do_encode::<u16, y4m::Decoder<'_, Box<dyn Read>>>(
|
||
|
+ do_encode::<u16, y4m::Decoder<Box<dyn Read>>>(
|
||
|
cfg,
|
||
|
cli.verbose,
|
||
|
progress,
|
||
|
&mut *cli.io.output,
|
||
|
- &mut source,
|
||
|
+ source,
|
||
|
cli.pass1file_name.as_ref(),
|
||
|
cli.pass2file_name.as_ref(),
|
||
|
y4m_enc,
|
||
|
--
|
||
|
2.26.2
|
||
|
|