Skip to content

Commit

Permalink
avifenc: Change default value of --jobs to "all"
Browse files Browse the repository at this point in the history
  • Loading branch information
wantehchang authored Nov 9, 2023
1 parent e939360 commit 4dd98ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
error instead of being ignored.
* API calls now return AVIF_RESULT_OUT_OF_MEMORY instead of aborting on memory
allocation failure.
* avifenc: Change the default value of the --jobs option from 1 to "all".

## [1.0.1] - 2023-08-29

Expand Down
8 changes: 6 additions & 2 deletions apps/avifenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static void syntaxLong(void)
AVIF_SPEED_FASTEST);
printf("\n");
printf("Advanced options:\n");
printf(" -j,--jobs J : Number of jobs (worker threads, default: 1. Use \"all\" to use all available cores)\n");
printf(" -j,--jobs J : Number of jobs (worker threads). Use \"all\" to potentially use as many cores as possible (default: all)\n");
printf(" --no-overwrite : Never overwrite existing output file\n");
printf(" -o,--output FILENAME : Instead of using the last filename given as output, use this filename\n");
#if defined(AVIF_ENABLE_EXPERIMENTAL_AVIR)
Expand Down Expand Up @@ -1422,7 +1422,7 @@ MAIN()
avifSettings settings;
memset(&settings, 0, sizeof(settings));
settings.codecChoice = AVIF_CODEC_CHOICE_AUTO;
settings.jobs = 1;
settings.jobs = -1;
settings.targetSize = -1;
settings.qualityIsConstrained = AVIF_FALSE;
settings.qualityAlphaIsConstrained = AVIF_FALSE;
Expand Down Expand Up @@ -1940,6 +1940,10 @@ MAIN()
++argIndex;
}

if (settings.jobs == -1) {
settings.jobs = avifQueryCPUCount();
}

// Check global lossless parameters and set to default if needed.
if (lossless) {
// Pixel format.
Expand Down
4 changes: 3 additions & 1 deletion src/codec_aom.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ static avifResult aomCodecEncodeImage(avifCodec * codec,
cfg->g_lag_in_frames = 0;
}
if (encoder->maxThreads > 1) {
cfg->g_threads = encoder->maxThreads;
// libaom fails if cfg->g_threads is greater than 64 threads. See MAX_NUM_THREADS in
// aom/aom_util/aom_thread.h.
cfg->g_threads = AVIF_MIN(encoder->maxThreads, 64);
}

codec->internal->monochromeEnabled = AVIF_FALSE;
Expand Down
4 changes: 3 additions & 1 deletion src/codec_avm.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,9 @@ static avifResult avmCodecEncodeImage(avifCodec * codec,
cfg->g_lag_in_frames = 0;
}
if (encoder->maxThreads > 1) {
cfg->g_threads = encoder->maxThreads;
// libavm fails if cfg->g_threads is greater than 64 threads. See MAX_NUM_THREADS in
// avm/aom_util/aom_thread.h.
cfg->g_threads = AVIF_MIN(encoder->maxThreads, 64);
}

// avm does not handle monochrome as of research-v4.0.0.
Expand Down

0 comments on commit 4dd98ef

Please sign in to comment.