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

Do parallel JPEG XL decoding

With this, my fancy intro is quite usable...
parent 77376487
No related branches found
No related tags found
No related merge requests found
Pipeline #7447 passed
...@@ -30,6 +30,7 @@ INCLUDE (CheckIncludeFiles) ...@@ -30,6 +30,7 @@ INCLUDE (CheckIncludeFiles)
find_package(PkgConfig) find_package(PkgConfig)
if(NOT WITHOUT_JPEG_XL) if(NOT WITHOUT_JPEG_XL)
pkg_check_modules(JPEG_XL libjxl) pkg_check_modules(JPEG_XL libjxl)
pkg_check_modules(JPEG_XL_THREADS libjxl_threads)
endif() endif()
set(SOURCE set(SOURCE
...@@ -138,6 +139,14 @@ if(NOT WITHOUT_JPEG_XL) ...@@ -138,6 +139,14 @@ if(NOT WITHOUT_JPEG_XL)
target_link_directories(syncterm PRIVATE ${JPEG_XL_LIBRARY_DIRS}) target_link_directories(syncterm PRIVATE ${JPEG_XL_LIBRARY_DIRS})
target_link_libraries(syncterm ${JPEG_XL_LIBRARIES}) target_link_libraries(syncterm ${JPEG_XL_LIBRARIES})
target_link_options(syncterm PRIVATE ${JPEG_XL_LDFLAGS}) target_link_options(syncterm PRIVATE ${JPEG_XL_LDFLAGS})
if(JPEG_XL_THREADS_FOUND)
target_compile_definitions(syncterm PUBLIC WITH_JPEG_XL_THREADS)
target_include_directories(syncterm PRIVATE ${JPEG_XL_THREADS_INCLUDE_DIRS})
target_compile_options(syncterm PRIVATE ${JPEG_XL_THREADS_CFLAGS})
target_link_directories(syncterm PRIVATE ${JPEG_XL_THREADS_LIBRARY_DIRS})
target_link_libraries(syncterm ${JPEG_XL_THREADS_LIBRARIES})
target_link_options(syncterm PRIVATE ${JPEG_XL_THREADS_LDFLAGS})
endif()
endif() endif()
endif() endif()
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#ifdef WITH_JPEG_XL #ifdef WITH_JPEG_XL
#include <jxl/decode.h> #include <jxl/decode.h>
#include <jxl/encode.h> #include <jxl/encode.h>
#include <jxl/resizable_parallel_runner.h>
#include "xpmap.h" #include "xpmap.h"
#endif #endif
...@@ -3112,6 +3113,13 @@ read_jxl(const char *fn) ...@@ -3112,6 +3113,13 @@ read_jxl(const char *fn)
xpunmap(map); xpunmap(map);
return NULL; return NULL;
} }
void *rpr = JxlResizableParallelRunnerCreate(NULL);
if (rpr) {
if (JxlDecoderSetParallelRunner(dec, JxlResizableParallelRunner, rpr) != JXL_DEC_SUCCESS) {
JxlResizableParallelRunnerDestroy(rpr);
rpr = NULL;
}
}
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);
...@@ -3136,6 +3144,7 @@ read_jxl(const char *fn) ...@@ -3136,6 +3144,7 @@ read_jxl(const char *fn)
} }
width = info.xsize; width = info.xsize;
height = info.ysize; height = info.ysize;
JxlResizableParallelRunnerSetThreads(rpr, JxlResizableParallelRunnerSuggestThreads(info.xsize, info.ysize));
break; break;
case JXL_DEC_COLOR_ENCODING: case JXL_DEC_COLOR_ENCODING:
// TODO... // TODO...
...@@ -3187,6 +3196,8 @@ read_jxl(const char *fn) ...@@ -3187,6 +3196,8 @@ read_jxl(const char *fn)
} }
} }
free(pbuf); free(pbuf);
if (rpr)
JxlResizableParallelRunnerDestroy(rpr);
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.
Finish editing this message first!
Please register or to comment