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
Branches
Tags
No related merge requests found
Pipeline #7447 passed
......@@ -30,6 +30,7 @@ INCLUDE (CheckIncludeFiles)
find_package(PkgConfig)
if(NOT WITHOUT_JPEG_XL)
pkg_check_modules(JPEG_XL libjxl)
pkg_check_modules(JPEG_XL_THREADS libjxl_threads)
endif()
set(SOURCE
......@@ -138,6 +139,14 @@ if(NOT WITHOUT_JPEG_XL)
target_link_directories(syncterm PRIVATE ${JPEG_XL_LIBRARY_DIRS})
target_link_libraries(syncterm ${JPEG_XL_LIBRARIES})
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()
......
......@@ -46,6 +46,7 @@
#ifdef WITH_JPEG_XL
#include <jxl/decode.h>
#include <jxl/encode.h>
#include <jxl/resizable_parallel_runner.h>
#include "xpmap.h"
#endif
......@@ -3112,6 +3113,13 @@ read_jxl(const char *fn)
xpunmap(map);
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) {
xpunmap(map);
JxlDecoderDestroy(dec);
......@@ -3136,6 +3144,7 @@ read_jxl(const char *fn)
}
width = info.xsize;
height = info.ysize;
JxlResizableParallelRunnerSetThreads(rpr, JxlResizableParallelRunnerSuggestThreads(info.xsize, info.ysize));
break;
case JXL_DEC_COLOR_ENCODING:
// TODO...
......@@ -3187,6 +3196,8 @@ read_jxl(const char *fn)
}
}
free(pbuf);
if (rpr)
JxlResizableParallelRunnerDestroy(rpr);
JxlDecoderReleaseInput(dec);
xpunmap(map);
JxlDecoderDestroy(dec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment