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