Skip to content

Commit

Permalink
grid: only use mutexes when multithreading support is enabled (#1377)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Nov 9, 2024
1 parent 4cf6b04 commit 3ce6149
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libheif/image-items/grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,11 @@ Error ImageItem_Grid::decode_and_paste_tile_image(heif_item_id tileID, uint32_t

// --- generate the image canvas for combining all the tiles

if (!inout_image) { // this if avoids that we normally have to lock a mutex
if (!inout_image) { // this avoids that we normally have to lock a mutex
#if ENABLE_MULTITHREADING_SUPPORT
static std::mutex createImageMutex;
std::lock_guard<std::mutex> lock(createImageMutex);
#endif

if (!inout_image) {
inout_image = std::make_shared<HeifPixelImage>();
Expand Down Expand Up @@ -479,8 +481,10 @@ Error ImageItem_Grid::decode_and_paste_tile_image(heif_item_id tileID, uint32_t
inout_image->copy_image_to(tile_img, x0, y0);

if (options.on_progress) {
#if ENABLE_MULTITHREADING_SUPPORT
static std::mutex progressMutex;
std::lock_guard<std::mutex> lock(progressMutex);
#endif

options.on_progress(heif_progress_step_total, ++progress_counter, options.progress_user_data);
}
Expand Down

0 comments on commit 3ce6149

Please sign in to comment.