Commit 7139d2ba for libheif
commit 7139d2ba980d97c45ab9a7b80ef2c98328ec2606
Author: Dinika Saxena <dinika@greyllama.cc>
Date: Mon Feb 2 18:46:13 2026 +0100
Fix: Set dav1d thread count before opening decoder
The num_threads setting was being applied after dav1d_open(),
which meant the thread configuration was ignored. Moving the
thread count assignment to occur before opening the decoder
so that the setting takes effect.
diff --git a/libheif/plugins/decoder_dav1d.cc b/libheif/plugins/decoder_dav1d.cc
index 38f82b95..8502f1c5 100644
--- a/libheif/plugins/decoder_dav1d.cc
+++ b/libheif/plugins/decoder_dav1d.cc
@@ -108,15 +108,15 @@ heif_error dav1d_new_decoder2(void** dec, const heif_decoder_plugin_options* opt
decoder->settings.all_layers = 0;
+ if (options->num_threads) {
+ decoder->settings.n_threads = options->num_threads;
+ }
+
if (dav1d_open(&decoder->context, &decoder->settings) != 0) {
delete decoder;
return {heif_error_Decoder_plugin_error, heif_suberror_Unspecified, kSuccess};
}
- if (options->num_threads) {
- decoder->settings.n_threads = options->num_threads;
- }
-
*dec = decoder;
return heif_error_ok;