File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -227,6 +227,18 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem_Grid::decode_compressed_image(
227227 }
228228}
229229
230+ #if ENABLE_PARALLEL_TILE_DECODING
231+ static void wait_for_jobs (std::deque<std::future<Error> >* jobs) {
232+ if (jobs->empty ()) {
233+ return ;
234+ }
235+
236+ while (!jobs->empty ()) {
237+ jobs->front ().get ();
238+ jobs->pop_front ();
239+ }
240+ }
241+ #endif
230242
231243Result<std::shared_ptr<HeifPixelImage>> ImageItem_Grid::decode_full_grid_image (const heif_decoding_options& options) const
232244{
@@ -372,11 +384,11 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem_Grid::decode_full_grid_image(c
372384
373385 if (errs.size () >= (size_t ) get_context ()->get_max_decoding_threads ()) {
374386 Error e = errs.front ().get ();
387+ errs.pop_front ();
375388 if (e) {
389+ wait_for_jobs (&errs);
376390 return e;
377391 }
378-
379- errs.pop_front ();
380392 }
381393
382394
@@ -402,11 +414,11 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem_Grid::decode_full_grid_image(c
402414
403415 while (!errs.empty ()) {
404416 Error e = errs.front ().get ();
417+ errs.pop_front ();
405418 if (e) {
419+ wait_for_jobs (&errs);
406420 return e;
407421 }
408-
409- errs.pop_front ();
410422 }
411423 }
412424#endif
You can’t perform that action at this time.
0 commit comments