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 committed Nov 7, 2023
1 parent 9157c74 commit 6db3f05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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 use all available cores (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 6db3f05

Please sign in to comment.