Skip to content

Commit

Permalink
AOM encoder: default number of threads should not exceed maximum (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Jul 8, 2024
1 parent 0d56f46 commit 6826a9d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libheif/plugins/encoder_aom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,17 @@ static void aom_init_parameters()
p->version = 2;
p->name = kParam_threads;
p->type = heif_encoder_parameter_type_integer;
unsigned int threads = std::thread::hardware_concurrency();
p->has_default = true;
p->integer.have_minimum_maximum = true;
p->integer.minimum = 1;
p->integer.maximum = 64;
int threads = static_cast<int>(std::thread::hardware_concurrency());
if (threads == 0) {
// Could not autodetect, use previous default value.
threads = 4;
}
threads = std::min(threads, p->integer.maximum);
p->integer.default_value = threads;
p->has_default = true;
p->integer.have_minimum_maximum = true;
p->integer.minimum = 1;
p->integer.maximum = 64;
p->integer.valid_values = NULL;
p->integer.num_valid_values = 0;
d[i++] = p++;
Expand Down

0 comments on commit 6826a9d

Please sign in to comment.