Skip to content
Snippets Groups Projects
Commit f6a44d14 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Properly handle the case where libjxl thread support is missing

parent de425670
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
#ifdef WITH_JPEG_XL #ifdef WITH_JPEG_XL
#include <jxl/decode.h> #include <jxl/decode.h>
#include <jxl/encode.h> #include <jxl/encode.h>
#ifdef WITH_JPEG_XL_THREADS
#include <jxl/resizable_parallel_runner.h> #include <jxl/resizable_parallel_runner.h>
#endif
#include "xpmap.h" #include "xpmap.h"
#endif #endif
...@@ -3113,6 +3115,7 @@ read_jxl(const char *fn) ...@@ -3113,6 +3115,7 @@ read_jxl(const char *fn)
xpunmap(map); xpunmap(map);
return NULL; return NULL;
} }
#ifdef WITH_JPEG_XL_THREADS
void *rpr = JxlResizableParallelRunnerCreate(NULL); void *rpr = JxlResizableParallelRunnerCreate(NULL);
if (rpr) { if (rpr) {
if (JxlDecoderSetParallelRunner(dec, JxlResizableParallelRunner, rpr) != JXL_DEC_SUCCESS) { if (JxlDecoderSetParallelRunner(dec, JxlResizableParallelRunner, rpr) != JXL_DEC_SUCCESS) {
...@@ -3120,6 +3123,7 @@ read_jxl(const char *fn) ...@@ -3120,6 +3123,7 @@ read_jxl(const char *fn)
rpr = NULL; rpr = NULL;
} }
} }
#endif
if (JxlDecoderSetInput(dec, map->addr, map->size) != JXL_DEC_SUCCESS) { if (JxlDecoderSetInput(dec, map->addr, map->size) != JXL_DEC_SUCCESS) {
xpunmap(map); xpunmap(map);
JxlDecoderDestroy(dec); JxlDecoderDestroy(dec);
...@@ -3144,7 +3148,9 @@ read_jxl(const char *fn) ...@@ -3144,7 +3148,9 @@ read_jxl(const char *fn)
} }
width = info.xsize; width = info.xsize;
height = info.ysize; height = info.ysize;
#ifdef WITH_JPEG_XL_THREADS
JxlResizableParallelRunnerSetThreads(rpr, JxlResizableParallelRunnerSuggestThreads(info.xsize, info.ysize)); JxlResizableParallelRunnerSetThreads(rpr, JxlResizableParallelRunnerSuggestThreads(info.xsize, info.ysize));
#endif
break; break;
case JXL_DEC_COLOR_ENCODING: case JXL_DEC_COLOR_ENCODING:
// TODO... // TODO...
...@@ -3196,8 +3202,10 @@ read_jxl(const char *fn) ...@@ -3196,8 +3202,10 @@ read_jxl(const char *fn)
} }
} }
free(pbuf); free(pbuf);
#ifdef WITH_JPEG_XL_THREADS
if (rpr) if (rpr)
JxlResizableParallelRunnerDestroy(rpr); JxlResizableParallelRunnerDestroy(rpr);
#endif
JxlDecoderReleaseInput(dec); JxlDecoderReleaseInput(dec);
xpunmap(map); xpunmap(map);
JxlDecoderDestroy(dec); JxlDecoderDestroy(dec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment