Add error code to returns
Fix conditional libjxl compilation
This commit is contained in:
parent
dfc82c403c
commit
dd01cc110b
@ -553,8 +553,8 @@ if(WITH_SYSTEM_KLT)
|
||||
endif()
|
||||
|
||||
pkg_check_modules(JXL IMPORTED_TARGET libjxl libjxl_threads)
|
||||
if(JXL)
|
||||
set(JXL_LIBRARIES jxl jxl_threads)
|
||||
if(JXL_FOUND)
|
||||
add_definitions(-DLIBJXL)
|
||||
endif()
|
||||
|
||||
# Check for libcanberra-gtk3 (sound events on Linux):
|
||||
|
@ -45,6 +45,9 @@ endif()
|
||||
if(EXIV2_INCLUDE_DIRS)
|
||||
include_directories("${EXIV2_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(JXL_INCLUDE_DIRS)
|
||||
include_directories("${JXL_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
link_directories(
|
||||
"${EXPAT_LIBRARY_DIRS}"
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <tiff.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
#include <fstream>
|
||||
#include "jxl/decode.h"
|
||||
#include "jxl/decode_cxx.h"
|
||||
@ -829,9 +829,8 @@ int ImageIO::loadTIFF (const Glib::ustring &fname)
|
||||
return IMIO_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
#define _PROFILE_ JXL_COLOR_PROFILE_TARGET_ORIGINAL
|
||||
|
||||
// adapted from libjxl
|
||||
int ImageIO::loadJxl(const Glib::ustring &fname)
|
||||
{
|
||||
@ -870,14 +869,14 @@ int ImageIO::loadJxl(const Glib::ustring &fname)
|
||||
JXL_DEC_COLOR_ENCODING |
|
||||
JXL_DEC_FULL_IMAGE)) {
|
||||
g_printerr("Error: JxlDecoderSubscribeEvents failed\n");
|
||||
return false;
|
||||
return IMIO_HEADERERROR;
|
||||
}
|
||||
|
||||
if (JXL_DEC_SUCCESS !=
|
||||
JxlDecoderSetParallelRunner(dec.get(), JxlResizableParallelRunner,
|
||||
runner.get())) {
|
||||
g_printerr("Error: JxlDecoderSetParallelRunner failed\n");
|
||||
return false;
|
||||
return IMIO_HEADERERROR;
|
||||
}
|
||||
|
||||
// grand decode loop...
|
||||
@ -890,7 +889,7 @@ int ImageIO::loadJxl(const Glib::ustring &fname)
|
||||
if (JXL_DEC_SUCCESS !=
|
||||
JxlDecoderGetBasicInfo(dec.get(), &info)) {
|
||||
g_printerr("Error: JxlDecoderGetBasicInfo failed\n");
|
||||
return false;
|
||||
return IMIO_HEADERERROR;
|
||||
}
|
||||
|
||||
JxlResizableParallelRunnerSetThreads(
|
||||
@ -928,14 +927,14 @@ int ImageIO::loadJxl(const Glib::ustring &fname)
|
||||
if (JXL_DEC_SUCCESS != JxlDecoderImageOutBufferSize(
|
||||
dec.get(), &format, &buffer_size)) {
|
||||
g_printerr("Error: JxlDecoderImageOutBufferSize failed\n");
|
||||
return false;
|
||||
return IMIO_READERROR;
|
||||
}
|
||||
buffer = g_malloc(buffer_size);
|
||||
if (JXL_DEC_SUCCESS != JxlDecoderSetImageOutBuffer(dec.get(), &format,
|
||||
buffer, buffer_size)) {
|
||||
g_printerr("Error: JxlDecoderSetImageOutBuffer failed\n");
|
||||
g_free(buffer);
|
||||
return false;
|
||||
return IMIO_READERROR;
|
||||
}
|
||||
} else if (status == JXL_DEC_FULL_IMAGE ||
|
||||
status == JXL_DEC_FRAME) {
|
||||
@ -948,13 +947,13 @@ int ImageIO::loadJxl(const Glib::ustring &fname)
|
||||
break;
|
||||
} else if (status == JXL_DEC_NEED_MORE_INPUT) {
|
||||
g_printerr("Error: Already provided all input\n");
|
||||
return false;
|
||||
return IMIO_READERROR;
|
||||
} else if (status == JXL_DEC_ERROR) {
|
||||
g_printerr("Error: Decoder error\n");
|
||||
return false;
|
||||
return IMIO_READERROR;
|
||||
} else {
|
||||
g_printerr("Error: Unknown decoder status\n");
|
||||
return false;
|
||||
return IMIO_READERROR;
|
||||
}
|
||||
} // end grand decode loop
|
||||
|
||||
@ -982,7 +981,8 @@ int ImageIO::loadJxl(const Glib::ustring &fname)
|
||||
|
||||
return IMIO_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#undef _PROFILE_
|
||||
#endif // LIBJXL
|
||||
|
||||
int ImageIO::loadPPMFromMemory(const char* buffer, int width, int height, bool swap, int bps)
|
||||
{
|
||||
@ -1472,7 +1472,7 @@ int ImageIO::load (const Glib::ustring &fname)
|
||||
return loadPNG (fname);
|
||||
} else if (hasJpegExtension(fname)) {
|
||||
return loadJPEG (fname);
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
} else if (hasJxlExtension(fname)) {
|
||||
return loadJxl(fname);
|
||||
#endif
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
int load (const Glib::ustring &fname);
|
||||
int save (const Glib::ustring &fname) const;
|
||||
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
int loadJxl (const Glib::ustring &fname);
|
||||
#endif
|
||||
|
||||
|
@ -90,7 +90,7 @@ void StdImageSource::getSampleFormat (const Glib::ustring &fname, IIOSampleForma
|
||||
if (result == IMIO_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
} else if (hasJxlExtension(fname)) {
|
||||
sFormat = IIOSF_FLOAT32;
|
||||
sArrangement = IIOSA_CHUNKY;
|
||||
|
@ -237,7 +237,7 @@ bool hasJpegExtension(const Glib::ustring& filename)
|
||||
return extension == "jpg" || extension == "jpeg";
|
||||
}
|
||||
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
bool hasJxlExtension(const Glib::ustring& filename)
|
||||
{
|
||||
const Glib::ustring extension = getFileExtension(filename);
|
||||
|
@ -52,7 +52,7 @@ bool hasTiffExtension(const Glib::ustring& filename);
|
||||
// Return true if file has .png extension (ignoring case)
|
||||
bool hasPngExtension(const Glib::ustring& filename);
|
||||
|
||||
#ifdef JXL
|
||||
#ifdef LIBJXL
|
||||
// Return true if file has .jxl extension (ignoring case)
|
||||
bool hasJxlExtension(const Glib::ustring& filename);
|
||||
#endif
|
||||
|
@ -707,7 +707,7 @@ int processLineParams ( int argc, char **argv )
|
||||
isRaw = true;
|
||||
Glib::ustring ext = getExtension (inputFile);
|
||||
|
||||
if (ext.lowercase() == "jpg" || ext.lowercase() == "jpeg" || ext.lowercase() == "tif" || ext.lowercase() == "tiff" || ext.lowercase() == "png" || ext.lowercase() == "jxl") {
|
||||
if (ext.lowercase() == "jpg" || ext.lowercase() == "jpeg" || ext.lowercase() == "tif" || ext.lowercase() == "tiff" || ext.lowercase() == "png") {
|
||||
isRaw = false;
|
||||
}
|
||||
|
||||
|
@ -212,18 +212,20 @@ void Thumbnail::_generateThumbnailImage ()
|
||||
if (tpp) {
|
||||
cfs.format = FT_Jpeg;
|
||||
}
|
||||
} else if (ext == "jxl") {
|
||||
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, -1, pparams->wb.equal);
|
||||
|
||||
if (tpp) {
|
||||
cfs.format = FT_Png;
|
||||
}
|
||||
} else if (ext == "png") {
|
||||
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, -1, pparams->wb.equal, pparams->wb.observer);
|
||||
|
||||
if (tpp) {
|
||||
cfs.format = FT_Png;
|
||||
}
|
||||
#ifdef LIBJXL
|
||||
} else if (ext == "jxl") {
|
||||
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, -1, pparams->wb.equal);
|
||||
|
||||
if (tpp) {
|
||||
cfs.format = FT_Custom;
|
||||
}
|
||||
#endif
|
||||
} else if (ext == "tif" || ext == "tiff") {
|
||||
infoFromImage (fname);
|
||||
tpp = rtengine::Thumbnail::loadFromImage (fname, tw, th, -1, pparams->wb.equal, pparams->wb.observer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user