Skip to content

Commit d9ee06a

Browse files
lu-zerorzumer
authored andcommitted
Avoid some indirection now that we can directly store the Writer/Reader in y4m
1 parent fff4653 commit d9ee06a

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/bin/rav1e.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn process_frame<T: Pixel, D: Decoder>(
234234

235235
fn do_encode<T: Pixel, D: Decoder>(
236236
cfg: Config, verbose: Verbose, mut progress: ProgressInfo,
237-
output: &mut dyn Muxer, source: &mut Source<D>, mut pass1file: Option<File>,
237+
output: &mut dyn Muxer, mut source: Source<D>, mut pass1file: Option<File>,
238238
mut pass2file: Option<File>,
239239
mut y4m_enc: Option<y4m::Encoder<Box<dyn Write>>>,
240240
metrics_enabled: MetricsEnabled,
@@ -248,7 +248,7 @@ fn do_encode<T: Pixel, D: Decoder>(
248248
while let Some(frame_info) = process_frame(
249249
&mut ctx,
250250
&mut *output,
251-
source,
251+
&mut source,
252252
pass1file.as_mut(),
253253
pass2file.as_mut(),
254254
&mut buffer,
@@ -378,15 +378,14 @@ fn run() -> Result<(), error::CliError> {
378378
.saturating_mul(2304)
379379
.saturating_add(1024),
380380
};
381-
let mut y4m_dec =
382-
match y4m::Decoder::new_with_limits(&mut cli.io.input, limit) {
383-
Err(_) => {
384-
return Err(CliError::new("Could not input video. Is it a y4m file?"))
385-
}
386-
Ok(d) => d,
387-
};
381+
let mut y4m_dec = match y4m::Decoder::new_with_limits(cli.io.input, limit) {
382+
Err(_) => {
383+
return Err(CliError::new("Could not input video. Is it a y4m file?"))
384+
}
385+
Ok(d) => d,
386+
};
388387
let video_info = y4m_dec.get_video_details();
389-
let y4m_enc = match cli.io.rec.as_mut() {
388+
let y4m_enc = match cli.io.rec {
390389
Some(rec) => Some(
391390
y4m::encode(
392391
video_info.width,
@@ -481,27 +480,27 @@ fn run() -> Result<(), error::CliError> {
481480
};
482481
}
483482

484-
let mut source = Source::new(cli.limit, y4m_dec);
483+
let source = Source::new(cli.limit, y4m_dec);
485484

486485
if video_info.bit_depth == 8 {
487-
do_encode::<u8, y4m::Decoder<'_, Box<dyn Read>>>(
486+
do_encode::<u8, y4m::Decoder<Box<dyn Read>>>(
488487
cfg,
489488
cli.verbose,
490489
progress,
491490
&mut *cli.io.output,
492-
&mut source,
491+
source,
493492
pass1file,
494493
pass2file,
495494
y4m_enc,
496495
cli.metrics_enabled,
497496
)?
498497
} else {
499-
do_encode::<u16, y4m::Decoder<'_, Box<dyn Read>>>(
498+
do_encode::<u16, y4m::Decoder<Box<dyn Read>>>(
500499
cfg,
501500
cli.verbose,
502501
progress,
503502
&mut *cli.io.output,
504-
&mut source,
503+
source,
505504
pass1file,
506505
pass2file,
507506
y4m_enc,

0 commit comments

Comments
 (0)