-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7656089
commit 6a8dbbe
Showing
5 changed files
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.y4m binary |
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 @@ | ||
!small_input.y4m |
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,93 @@ | ||
#[cfg(feature = "binaries")] | ||
mod binary { | ||
use assert_cmd::Command; | ||
use rand::distributions::Alphanumeric; | ||
use rand::{thread_rng, Rng}; | ||
use std::env::temp_dir; | ||
use std::fs::File; | ||
use std::io::Read; | ||
use std::path::PathBuf; | ||
|
||
fn get_y4m_input() -> Vec<u8> { | ||
let mut input = File::open(&format!( | ||
"{}/tests/small_input.y4m", | ||
env!("CARGO_MANIFEST_DIR") | ||
)) | ||
.unwrap(); | ||
let mut data = Vec::new(); | ||
input.read_to_end(&mut data).unwrap(); | ||
data | ||
} | ||
|
||
fn get_tempfile_path(extension: &str) -> PathBuf { | ||
let mut path = temp_dir(); | ||
let filename = | ||
thread_rng().sample_iter(&Alphanumeric).take(12).collect::<String>(); | ||
path.push(format!("{}.{}", filename, extension)); | ||
path | ||
} | ||
|
||
#[test] | ||
fn one_pass_qp_based() { | ||
let mut cmd = Command::cargo_bin("rav1e").unwrap(); | ||
let outfile = get_tempfile_path("ivf"); | ||
|
||
cmd | ||
.arg("--quantizer") | ||
.arg("100") | ||
.arg("-o") | ||
.arg(&outfile) | ||
.arg("-") | ||
.write_stdin(get_y4m_input()) | ||
.assert() | ||
.success(); | ||
} | ||
|
||
#[test] | ||
fn one_pass_bitrate_based() { | ||
let mut cmd = Command::cargo_bin("rav1e").unwrap(); | ||
let outfile = get_tempfile_path("ivf"); | ||
|
||
cmd | ||
.arg("--bitrate") | ||
.arg("1000") | ||
.arg("-o") | ||
.arg(&outfile) | ||
.arg("-") | ||
.write_stdin(get_y4m_input()) | ||
.assert() | ||
.success(); | ||
} | ||
|
||
#[test] | ||
fn two_pass_bitrate_based() { | ||
let outfile = get_tempfile_path("ivf"); | ||
let passfile = get_tempfile_path("pass"); | ||
|
||
let mut cmd1 = Command::cargo_bin("rav1e").unwrap(); | ||
cmd1 | ||
.arg("--bitrate") | ||
.arg("1000") | ||
.arg("-o") | ||
.arg(&outfile) | ||
.arg("--first-pass") | ||
.arg(&passfile) | ||
.arg("-") | ||
.write_stdin(get_y4m_input()) | ||
.assert() | ||
.success(); | ||
|
||
let mut cmd2 = Command::cargo_bin("rav1e").unwrap(); | ||
cmd2 | ||
.arg("--bitrate") | ||
.arg("1000") | ||
.arg("-o") | ||
.arg(&outfile) | ||
.arg("--second-pass") | ||
.arg(&passfile) | ||
.arg("-") | ||
.write_stdin(get_y4m_input()) | ||
.assert() | ||
.success(); | ||
} | ||
} |
Oops, something went wrong.