Skip to content

Commit

Permalink
added threads option
Browse files Browse the repository at this point in the history
  • Loading branch information
SalOne22 committed Oct 8, 2023
1 parent aa9d3bd commit 704eea2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the Rimage library will be documented in this file.

## **[Unreleased]** v0.9.1

### New features

- Added previously removed `--threads` option when parallel feature is enabled

## [v0.9.0](https://github.com/SalOne22/rimage/releases/tag/v0.9.0)

### Breaking Changes
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

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

11 changes: 11 additions & 0 deletions src/bin/rimage/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ fn main() -> Result<(), Box<dyn Error>> {
arg!(-s --suffix [SUFFIX] "Appends suffix to output file(s) names"),
arg!(-b --backup "Appends '.backup' to input file(s) names")
.action(ArgAction::SetTrue),
#[cfg(feature = "parallel")]
arg!(-t --threads "Number of threads to use [default: number of cores]")
.value_parser(value_parser!(usize)),
])
.next_help_heading("Quantization")
.args([
Expand All @@ -59,6 +62,14 @@ fn main() -> Result<(), Box<dyn Error>> {
let codec = matches.get_one::<Codec>("codec").unwrap();
let quality = matches.get_one::<f32>("quality").unwrap();

#[cfg(feature = "parallel")]
if let Some(threads) = matches.get_one::<usize>("threads") {
rayon::ThreadPoolBuilder::new()
.num_threads(*threads)
.build_global()
.unwrap();
}

let mut quantization_config = QuantizationConfig::new();

if let Some(quality) = matches.get_one::<u8>("quantization") {
Expand Down

0 comments on commit 704eea2

Please sign in to comment.