darktable ver. bump
This commit is contained in:
@@ -1,920 +0,0 @@
|
||||
From 74ca29440e46136504ed6fc811ccd60da8af8abc Mon Sep 17 00:00:00 2001
|
||||
From: David Bremner <david@tethera.net>
|
||||
Date: Wed, 26 Oct 2016 22:18:48 -0300
|
||||
Subject: [PATCH 1/3] debcherry fixup patch
|
||||
|
||||
88800f7 J2K: use g_strlcpy() instead of g_snprintf()
|
||||
- no changes against upstream or conflicts
|
||||
c6e0b7c FindOpenJPEG.cmake: use HINTS, not PATHS. NO_DEFAULT_PATH is not needed.
|
||||
- no changes against upstream or conflicts
|
||||
5cf698f Port to OpenJPEG2
|
||||
- extra changes or conflicts
|
||||
6f48d69 FindOpenJPEG.cmake: pick right include path if multiple headers.
|
||||
- extra changes or conflicts
|
||||
acf974a Update cmake stuff to look for OpenJPEG2 (openjpeg >= 2.0.0 aka openjp2)
|
||||
- extra changes or conflicts
|
||||
ecef362 restore upstream TODO
|
||||
- no changes against upstream or conflicts
|
||||
898199a debian: cleanup useless / missing docs
|
||||
- extra changes or conflicts
|
||||
31da456 remove dcraw.c again
|
||||
- no changes against upstream or conflicts
|
||||
4c3f916 remove dcraw.c
|
||||
- no changes against upstream or conflicts
|
||||
3b395b6 "undelete" some files now shipped in upstream tarball
|
||||
- extra changes or conflicts
|
||||
7d30472 remove version.h from git; generate it at build time
|
||||
- no changes against upstream or conflicts
|
||||
7441226 remove version.sh, unneeded for build
|
||||
- no changes against upstream or conflicts
|
||||
b0be4a0 commit version.h, version.sh for new version
|
||||
- extra changes or conflicts
|
||||
b5784e1 commit version.sh for current upstream snapshot
|
||||
- extra changes or conflicts
|
||||
cea1f68 remove generated files that are no longer carried in upstream branch (since we are not going to import them from tarballs.
|
||||
- extra changes or conflicts
|
||||
f67ef8e Revert "As a workaround, add files to POTFILES.skip"
|
||||
- extra changes or conflicts
|
||||
f6a4d09 As a workaround, add files to POTFILES.skip
|
||||
- extra changes or conflicts
|
||||
1eb15b3 Imported Upstream version 0.5
|
||||
- extra changes or conflicts
|
||||
---
|
||||
cmake/modules/FindOpenJPEG.cmake | 112 ++++---------------
|
||||
src/CMakeLists.txt | 17 +--
|
||||
src/common/imageio_j2k.c | 228 ++++++++++++++++++++++----------------
|
||||
src/imageio/format/CMakeLists.txt | 4 +-
|
||||
src/imageio/format/j2k.c | 130 +++++++++++-----------
|
||||
5 files changed, 224 insertions(+), 267 deletions(-)
|
||||
|
||||
diff --git a/cmake/modules/FindOpenJPEG.cmake b/cmake/modules/FindOpenJPEG.cmake
|
||||
index b80f922..da6d275 100644
|
||||
--- a/cmake/modules/FindOpenJPEG.cmake
|
||||
+++ b/cmake/modules/FindOpenJPEG.cmake
|
||||
@@ -1,101 +1,29 @@
|
||||
-# - Find OpenJPEG library
|
||||
-# Find the native OpenJPEG includes and library
|
||||
-# This module defines
|
||||
-# OPENJPEG_INCLUDE_DIRS, where to find openjpeg.h, Set when
|
||||
-# OPENJPEG_INCLUDE_DIR is found.
|
||||
-# OPENJPEG_LIBRARIES, libraries to link against to use OpenJPEG.
|
||||
-# OPENJPEG_ROOT_DIR, The base directory to search for OpenJPEG.
|
||||
-# This can also be an environment variable.
|
||||
-# OPENJPEG_FOUND, If false, do not try to use OpenJPEG.
|
||||
+# - Try to find OpenJPEG
|
||||
+# Once done, this will define
|
||||
#
|
||||
-# also defined, but not for general use are
|
||||
-# OPENJPEG_LIBRARY, where to find the OpenJPEG library.
|
||||
-
|
||||
-#=============================================================================
|
||||
-# Copyright 2011 Blender Foundation.
|
||||
-#
|
||||
-# Distributed under the OSI-approved BSD License (the "License");
|
||||
-# see accompanying file Copyright.txt for details.
|
||||
-#
|
||||
-# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
-# See the License for more information.
|
||||
-#=============================================================================
|
||||
-
|
||||
-# If OPENJPEG_ROOT_DIR was defined in the environment, use it.
|
||||
-IF(NOT OPENJPEG_ROOT_DIR AND NOT $ENV{OPENJPEG_ROOT_DIR} STREQUAL "")
|
||||
- SET(OPENJPEG_ROOT_DIR $ENV{OPENJPEG_ROOT_DIR})
|
||||
-ENDIF()
|
||||
+# OpenJPEG_FOUND - system has OpenJPEG
|
||||
+# OpenJPEG_INCLUDE_DIRS - the OpenJPEG include directories
|
||||
+# OpenJPEG_LIBRARIES - link these to use OpenJPEG
|
||||
|
||||
include(LibFindMacros)
|
||||
|
||||
-libfind_pkg_check_modules(PC_OPENJPEG libopenjpeg1)
|
||||
+# Use pkg-config to get hints about paths
|
||||
+libfind_pkg_check_modules(OpenJPEG_PKGCONF libopenjp2)
|
||||
|
||||
-SET(_openjpeg_SEARCH_DIRS
|
||||
- ${OPENJPEG_ROOT_DIR}
|
||||
- /usr/local
|
||||
- /sw # Fink
|
||||
- /opt/local # DarwinPorts
|
||||
- /opt/csw # Blastwave
|
||||
+# Include dir
|
||||
+find_path(OpenJPEG_INCLUDE_DIR
|
||||
+ NAMES openjpeg.h
|
||||
+ HINTS ${OpenJPEG_PKGCONF_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
-FIND_PATH(OPENJPEG_INCLUDE_DIR
|
||||
- NAMES
|
||||
- openjpeg.h
|
||||
- HINTS
|
||||
- ${PC_OPENJPEG_INCLUDEDIR}
|
||||
- ${PC_OPENJPEG_INCLUDE_DIRS}
|
||||
- ${_openjpeg_SEARCH_DIRS}
|
||||
- PATH_SUFFIXES
|
||||
- include
|
||||
+# Finally the library itself
|
||||
+find_library(OpenJPEG_LIBRARY
|
||||
+ NAMES openjp2
|
||||
+ HINTS ${OpenJPEG_PKGCONF_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
-FIND_LIBRARY(OPENJPEG_LIBRARY
|
||||
- NAMES
|
||||
- openjpeg
|
||||
- HINTS
|
||||
- ${PC_OPENJPEG_LIBDIR}
|
||||
- ${PC_OPENJPEG_LIBRARY_DIRS}
|
||||
- ${_openjpeg_SEARCH_DIRS}
|
||||
- PATH_SUFFIXES
|
||||
- lib64 lib
|
||||
- )
|
||||
-
|
||||
-# handle the QUIETLY and REQUIRED arguments and set OPENJPEG_FOUND to TRUE if
|
||||
-# all listed variables are TRUE
|
||||
-INCLUDE(FindPackageHandleStandardArgs)
|
||||
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenJPEG DEFAULT_MSG
|
||||
- OPENJPEG_LIBRARY OPENJPEG_INCLUDE_DIR)
|
||||
-
|
||||
-IF(OPENJPEG_FOUND)
|
||||
- SET(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY})
|
||||
- SET(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR})
|
||||
-
|
||||
- # 1.3 didn't have pkg-config support, so we can't use that to get the version.
|
||||
- # 1.5 no longer has the #define OPENJPEG_VERSION ... in openjpeg.h so we can't use that either.
|
||||
- # Thus we might have to compile a smalltest program to get the version string. Could someone please kill me?
|
||||
-
|
||||
- # see if pkg-config found the library. this should succeed for cross compiles as they are harder to run test programs
|
||||
- if(NOT "${PC_OPENJPEG_VERSION}" STREQUAL "")
|
||||
- # use the version as found by pkg-config
|
||||
- set(OPENJPEG_VERSION ${PC_OPENJPEG_VERSION})
|
||||
- else(NOT "${PC_OPENJPEG_VERSION}" STREQUAL "")
|
||||
- # too bad, we have to run our test code
|
||||
- try_run(run_var result_var
|
||||
- ${CMAKE_BINARY_DIR}/CMakeTmp
|
||||
- ${CMAKE_SOURCE_DIR}/cmake/modules/openjpeg_version.c
|
||||
- CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${OPENJPEG_LIBRARIES}"
|
||||
- "-DINCLUDE_DIRECTORIES:STRING=${OPENJPEG_INCLUDE_DIRS}"
|
||||
- RUN_OUTPUT_VARIABLE rout_var
|
||||
- )
|
||||
- if(result_var)
|
||||
- set(OPENJPEG_VERSION ${rout_var})
|
||||
- endif(result_var)
|
||||
- endif(NOT "${PC_OPENJPEG_VERSION}" STREQUAL "")
|
||||
-
|
||||
-ENDIF(OPENJPEG_FOUND)
|
||||
-
|
||||
-MARK_AS_ADVANCED(
|
||||
- OPENJPEG_INCLUDE_DIR
|
||||
- OPENJPEG_LIBRARY
|
||||
-)
|
||||
+# Set the include dir variables and the libraries and let libfind_process do the rest.
|
||||
+# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
|
||||
+set(OpenJPEG_PROCESS_INCLUDES OpenJPEG_INCLUDE_DIR)
|
||||
+set(OpenJPEG_PROCESS_LIBS OpenJPEG_LIBRARY)
|
||||
+libfind_process(OpenJPEG)
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 9278d91..7d29528 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -225,18 +225,13 @@ endif(USE_FLICKR)
|
||||
|
||||
if(USE_OPENJPEG)
|
||||
find_package(OpenJPEG)
|
||||
- if(OPENJPEG_FOUND)
|
||||
- list(APPEND SOURCES "common/imageio_j2k.c")
|
||||
- include_directories(SYSTEM ${OPENJPEG_INCLUDE_DIRS})
|
||||
- list(APPEND LIBS ${OPENJPEG_LIBRARIES})
|
||||
- add_definitions(${OPENJPEG_DEFINITIONS})
|
||||
+ if(OpenJPEG_FOUND)
|
||||
add_definitions("-DHAVE_OPENJPEG")
|
||||
- if(OPENJPEG_VERSION VERSION_LESS "1.5.0")
|
||||
- message(STATUS "OpenJPEG version ${OPENJPEG_VERSION} found. Only 1.5 and newer support reading of icc profiles.")
|
||||
- else()
|
||||
- add_definitions("-DHAVE_OPENJPEG_ICC")
|
||||
- endif()
|
||||
- endif(OPENJPEG_FOUND)
|
||||
+ list(APPEND SOURCES "common/imageio_j2k.c")
|
||||
+
|
||||
+ include_directories(SYSTEM ${OpenJPEG_INCLUDE_DIRS})
|
||||
+ list(APPEND LIBS ${OpenJPEG_LIBRARIES})
|
||||
+ endif(OpenJPEG_FOUND)
|
||||
endif(USE_OPENJPEG)
|
||||
|
||||
#
|
||||
diff --git a/src/common/imageio_j2k.c b/src/common/imageio_j2k.c
|
||||
index 84bcd28..7f60e7f 100644
|
||||
--- a/src/common/imageio_j2k.c
|
||||
+++ b/src/common/imageio_j2k.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#define JPT_CFMT 2
|
||||
|
||||
static char JP2_HEAD[] = { 0x0, 0x0, 0x0, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A };
|
||||
+static char JP2_MAGIC[] = { 0x0d, 0x0a, 0x87, 0x0a };
|
||||
static char J2K_HEAD[] = { 0xFF, 0x4F, 0xFF, 0x51, 0x00 };
|
||||
// there seems to be no JPIP/JPT magic string, so we can't load it ...
|
||||
|
||||
@@ -74,7 +75,7 @@ static int get_file_format(const char *filename)
|
||||
char *ext = strrchr(filename, '.');
|
||||
if(ext == NULL) return -1;
|
||||
ext++;
|
||||
- if(ext)
|
||||
+ if(*ext)
|
||||
{
|
||||
for(i = 0; i < sizeof(format) / sizeof(*format); i++)
|
||||
{
|
||||
@@ -91,100 +92,116 @@ static int get_file_format(const char *filename)
|
||||
dt_imageio_retval_t dt_imageio_open_j2k(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
|
||||
{
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
- opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
FILE *fsrc = NULL;
|
||||
- unsigned char *src = NULL;
|
||||
- size_t file_length;
|
||||
- opj_dinfo_t *dinfo = NULL; /* handle to a decompressor */
|
||||
- opj_cio_t *cio = NULL;
|
||||
+ unsigned char src_header[12] = { 0 };
|
||||
+ opj_codec_t *d_codec = NULL;
|
||||
OPJ_CODEC_FORMAT codec;
|
||||
+ opj_stream_t *d_stream = NULL; /* Stream */
|
||||
int ret = DT_IMAGEIO_FILE_CORRUPTED;
|
||||
|
||||
- int file_format = get_file_format(filename);
|
||||
- if(file_format == -1) return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ /* set decoding parameters to default values */
|
||||
+ opj_set_default_decoder_parameters(¶meters);
|
||||
+
|
||||
+ g_strlcpy(parameters.infile, filename, sizeof(parameters.infile));
|
||||
+
|
||||
+ parameters.decod_format = get_file_format(filename);
|
||||
+ if(parameters.decod_format == -1) return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
|
||||
if(!img->exif_inited) (void)dt_exif_read(img, filename);
|
||||
|
||||
- /* read the input file and put it in memory */
|
||||
- /* ---------------------------------------- */
|
||||
fsrc = fopen(filename, "rb");
|
||||
if(!fsrc)
|
||||
{
|
||||
fprintf(stderr, "[j2k_open] Error: failed to open `%s' for reading\n", filename);
|
||||
return DT_IMAGEIO_FILE_NOT_FOUND;
|
||||
}
|
||||
- fseek(fsrc, 0, SEEK_END);
|
||||
- file_length = ftell(fsrc);
|
||||
- fseek(fsrc, 0, SEEK_SET);
|
||||
- src = (unsigned char *)malloc(file_length);
|
||||
- if(fread(src, 1, file_length, fsrc) != file_length)
|
||||
+ if(fread(src_header, 1, 12, fsrc) != 12)
|
||||
{
|
||||
- free(src);
|
||||
fclose(fsrc);
|
||||
fprintf(stderr, "[j2k_open] Error: fread returned a number of elements different from the expected.\n");
|
||||
return DT_IMAGEIO_FILE_NOT_FOUND;
|
||||
}
|
||||
fclose(fsrc);
|
||||
|
||||
- if(memcmp(JP2_HEAD, src, sizeof(JP2_HEAD)) == 0)
|
||||
+ if(memcmp(JP2_HEAD, src_header, sizeof(JP2_HEAD)) == 0 || memcmp(JP2_MAGIC, src_header, sizeof(JP2_MAGIC)) == 0)
|
||||
{
|
||||
- file_format = JP2_CFMT; // just in case someone used the wrong extension
|
||||
+ parameters.decod_format = JP2_CFMT; // just in case someone used the wrong extension
|
||||
}
|
||||
- else if(memcmp(J2K_HEAD, src, sizeof(J2K_HEAD)) == 0)
|
||||
+ else if(memcmp(J2K_HEAD, src_header, sizeof(J2K_HEAD)) == 0)
|
||||
{
|
||||
- file_format = J2K_CFMT; // just in case someone used the wrong extension
|
||||
+ parameters.decod_format = J2K_CFMT; // just in case someone used the wrong extension
|
||||
}
|
||||
else // this will also reject jpt files.
|
||||
{
|
||||
- free(src);
|
||||
fprintf(stderr, "[j2k_open] Error: `%s' has unsupported file format.\n", filename);
|
||||
return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
- /* configure the event callbacks (not required) */
|
||||
- memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
- event_mgr.error_handler = error_callback;
|
||||
- // event_mgr.warning_handler = warning_callback;
|
||||
- // event_mgr.info_handler = info_callback;
|
||||
-
|
||||
- /* set decoding parameters to default values */
|
||||
- opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
- if(file_format == J2K_CFMT) /* JPEG-2000 codestream */
|
||||
- codec = CODEC_J2K;
|
||||
- else if(file_format == JP2_CFMT) /* JPEG 2000 compressed image data */
|
||||
- codec = CODEC_JP2;
|
||||
- else if(file_format == JPT_CFMT) /* JPEG 2000, JPIP */
|
||||
- codec = CODEC_JPT;
|
||||
+ if(parameters.decod_format == J2K_CFMT) /* JPEG-2000 codestream */
|
||||
+ codec = OPJ_CODEC_J2K;
|
||||
+ else if(parameters.decod_format == JP2_CFMT) /* JPEG 2000 compressed image data */
|
||||
+ codec = OPJ_CODEC_JP2;
|
||||
+ else if(parameters.decod_format == JPT_CFMT) /* JPEG 2000, JPIP */
|
||||
+ codec = OPJ_CODEC_JPT;
|
||||
else
|
||||
{
|
||||
- free(src);
|
||||
return DT_IMAGEIO_FILE_CORRUPTED; // can't happen
|
||||
}
|
||||
|
||||
- /* get a decoder handle */
|
||||
- dinfo = opj_create_decompress(codec);
|
||||
+ d_codec = opj_create_decompress(codec);
|
||||
+ if(!d_codec)
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_open] Error: failed to create the decoder\n");
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
- opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
+ opj_set_error_handler(d_codec, error_callback, stderr);
|
||||
+ // opj_set_warning_handler(d_codec, error_callback, stderr);
|
||||
+ // opj_set_info_handler(d_codec, error_callback, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
- opj_setup_decoder(dinfo, ¶meters);
|
||||
+ if(!opj_setup_decoder(d_codec, ¶meters))
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_open] Error: failed to setup the decoder %s\n", parameters.infile);
|
||||
+ opj_destroy_codec(d_codec);
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
- /* open a byte stream */
|
||||
- cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
+ d_stream = opj_stream_create_default_file_stream(parameters.infile, 1);
|
||||
+ if(!d_stream)
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_open] Error: failed to create the stream from the file %s\n", parameters.infile);
|
||||
+ opj_destroy_codec(d_codec);
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
- /* decode the stream and fill the image structure */
|
||||
- image = opj_decode(dinfo, cio);
|
||||
+ /* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
+ if(!opj_read_header(d_stream, d_codec, &image))
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_open] Error: failed to read the header\n");
|
||||
+ opj_stream_destroy(d_stream);
|
||||
+ opj_destroy_codec(d_codec);
|
||||
+ opj_image_destroy(image);
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
|
||||
- /* close the byte stream */
|
||||
- opj_cio_close(cio);
|
||||
+ /* Get the decoded image */
|
||||
+ if(!(opj_decode(d_codec, d_stream, image) && opj_end_decompress(d_codec, d_stream)))
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_open] Error: failed to decode image!\n");
|
||||
+ opj_destroy_codec(d_codec);
|
||||
+ opj_stream_destroy(d_stream);
|
||||
+ opj_image_destroy(image);
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
- /* free the memory containing the code-stream */
|
||||
- free(src);
|
||||
+ /* Close the byte stream */
|
||||
+ opj_stream_destroy(d_stream);
|
||||
|
||||
if(!image)
|
||||
{
|
||||
@@ -193,14 +210,11 @@ dt_imageio_retval_t dt_imageio_open_j2k(dt_image_t *img, const char *filename, d
|
||||
goto end_of_the_world;
|
||||
}
|
||||
|
||||
- if(image->color_space == CLRSPC_SYCC)
|
||||
+ if(image->color_space == OPJ_CLRSPC_SYCC)
|
||||
{
|
||||
color_sycc_to_rgb(image);
|
||||
}
|
||||
|
||||
-// FIXME: openjpeg didn't have support for icc profiles before version 1.5
|
||||
-// this needs some #ifdef magic and proper implementation
|
||||
-#ifdef HAVE_OPENJPEG_ICC
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
||||
@@ -211,7 +225,6 @@ dt_imageio_retval_t dt_imageio_open_j2k(dt_image_t *img, const char *filename, d
|
||||
image->icc_profile_buf = NULL;
|
||||
image->icc_profile_len = 0;
|
||||
}
|
||||
-#endif
|
||||
|
||||
/* create output image */
|
||||
/* ------------------- */
|
||||
@@ -289,7 +302,7 @@ dt_imageio_retval_t dt_imageio_open_j2k(dt_image_t *img, const char *filename, d
|
||||
|
||||
end_of_the_world:
|
||||
/* free remaining structures */
|
||||
- if(dinfo) opj_destroy_decompress(dinfo);
|
||||
+ opj_destroy_codec(d_codec);
|
||||
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
@@ -299,83 +312,113 @@ end_of_the_world:
|
||||
|
||||
int dt_imageio_j2k_read_profile(const char *filename, uint8_t **out)
|
||||
{
|
||||
-#ifdef HAVE_OPENJPEG_ICC
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
opj_image_t *image = NULL;
|
||||
FILE *fsrc = NULL;
|
||||
- unsigned char *src = NULL;
|
||||
- size_t file_length;
|
||||
- opj_dinfo_t *dinfo = NULL; /* handle to a decompressor */
|
||||
- opj_cio_t *cio = NULL;
|
||||
+ unsigned char src_header[12] = { 0 };
|
||||
+ opj_codec_t *d_codec = NULL;
|
||||
OPJ_CODEC_FORMAT codec;
|
||||
+ opj_stream_t *d_stream = NULL; /* Stream */
|
||||
gboolean res = FALSE;
|
||||
unsigned int length = 0;
|
||||
*out = NULL;
|
||||
|
||||
+ /* set decoding parameters to default values */
|
||||
+ opj_set_default_decoder_parameters(¶meters);
|
||||
+
|
||||
+ g_strlcpy(parameters.infile, filename, sizeof(parameters.infile));
|
||||
+
|
||||
+ parameters.decod_format = get_file_format(filename);
|
||||
+ if(parameters.decod_format == -1) return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fsrc = fopen(filename, "rb");
|
||||
if(!fsrc)
|
||||
{
|
||||
- fprintf(stderr, "[j2k_open] Error: failed to open `%s' for reading\n", filename);
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to open `%s' for reading\n", filename);
|
||||
goto another_end_of_the_world;
|
||||
}
|
||||
- fseek(fsrc, 0, SEEK_END);
|
||||
- file_length = ftell(fsrc);
|
||||
- fseek(fsrc, 0, SEEK_SET);
|
||||
- src = (unsigned char *)malloc(file_length);
|
||||
- if(fread(src, 1, file_length, fsrc) != file_length)
|
||||
+ if(fread(src_header, 1, 12, fsrc) != 12)
|
||||
{
|
||||
- free(src);
|
||||
fclose(fsrc);
|
||||
- fprintf(stderr, "[j2k_open] Error: fread returned a number of elements different from the expected.\n");
|
||||
+ fprintf(stderr,
|
||||
+ "[j2k_read_profile] Error: fread returned a number of elements different from the expected.\n");
|
||||
goto another_end_of_the_world;
|
||||
}
|
||||
fclose(fsrc);
|
||||
|
||||
- if(memcmp(JP2_HEAD, src, sizeof(JP2_HEAD)) == 0)
|
||||
+ if(memcmp(JP2_HEAD, src_header, sizeof(JP2_HEAD)) == 0 || memcmp(JP2_MAGIC, src_header, sizeof(JP2_MAGIC)) == 0)
|
||||
{
|
||||
- codec = CODEC_JP2;
|
||||
+ codec = OPJ_CODEC_JP2;
|
||||
}
|
||||
- else if(memcmp(J2K_HEAD, src, sizeof(J2K_HEAD)) == 0)
|
||||
+ else if(memcmp(J2K_HEAD, src_header, sizeof(J2K_HEAD)) == 0)
|
||||
{
|
||||
- codec = CODEC_J2K;
|
||||
+ codec = OPJ_CODEC_J2K;
|
||||
}
|
||||
else // this will also reject jpt files.
|
||||
{
|
||||
- free(src);
|
||||
- fprintf(stderr, "[j2k_open] Error: `%s' has unsupported file format.\n", filename);
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: `%s' has unsupported file format.\n", filename);
|
||||
goto another_end_of_the_world;
|
||||
}
|
||||
|
||||
- /* set decoding parameters to default values */
|
||||
- opj_set_default_decoder_parameters(¶meters);
|
||||
- parameters.cp_limit_decoding = LIMIT_TO_MAIN_HEADER;
|
||||
-
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
/* get a decoder handle */
|
||||
- dinfo = opj_create_decompress(codec);
|
||||
+ d_codec = opj_create_decompress(codec);
|
||||
+ if(!d_codec)
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to create the decoder\n");
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
- opj_setup_decoder(dinfo, ¶meters);
|
||||
+ opj_setup_decoder(d_codec, ¶meters);
|
||||
+ if(!d_codec)
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to setup the decoder %s\n", parameters.infile);
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
- /* open a byte stream */
|
||||
- cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
+ d_stream = opj_stream_create_default_file_stream(parameters.infile, 1);
|
||||
+ if(!d_stream)
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to create the stream from the file %s\n", parameters.infile);
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
- /* decode the stream and fill the image structure */
|
||||
- image = opj_decode(dinfo, cio);
|
||||
+ /* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
+ if(!opj_read_header(d_stream, d_codec, &image))
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to read the header\n");
|
||||
+ opj_stream_destroy(d_stream);
|
||||
+ opj_destroy_codec(d_codec);
|
||||
+ opj_image_destroy(image);
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
|
||||
- /* close the byte stream */
|
||||
- opj_cio_close(cio);
|
||||
+ /* Get the decoded image */
|
||||
+ if(!(opj_decode(d_codec, d_stream, image) && opj_end_decompress(d_codec, d_stream)))
|
||||
+ {
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to decode image!\n");
|
||||
+ opj_destroy_codec(d_codec);
|
||||
+ opj_stream_destroy(d_stream);
|
||||
+ opj_image_destroy(image);
|
||||
+ return DT_IMAGEIO_FILE_CORRUPTED;
|
||||
+ }
|
||||
|
||||
- /* free the memory containing the code-stream */
|
||||
- free(src);
|
||||
+ // FIXME: how to do it without fully-decoding the whole image?
|
||||
+ // opj_jp2_decode() copies the icc_profile_{buf,len}
|
||||
+ // from opj_codec_t *d_codec d_codec->color into opj_image_t *image, but
|
||||
+ // opj_codec_t is private type.
|
||||
+
|
||||
+ /* Close the byte stream */
|
||||
+ opj_stream_destroy(d_stream);
|
||||
|
||||
if(!image)
|
||||
{
|
||||
- fprintf(stderr, "[j2k_open] Error: failed to decode image `%s'\n", filename);
|
||||
+ fprintf(stderr, "[j2k_read_profile] Error: failed to decode image `%s'\n", filename);
|
||||
goto another_end_of_the_world;
|
||||
}
|
||||
|
||||
@@ -391,15 +434,12 @@ int dt_imageio_j2k_read_profile(const char *filename, uint8_t **out)
|
||||
|
||||
another_end_of_the_world:
|
||||
/* free remaining structures */
|
||||
- if(dinfo) opj_destroy_decompress(dinfo);
|
||||
+ opj_destroy_codec(d_codec);
|
||||
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
|
||||
return res ? length : 0;
|
||||
-#else
|
||||
- return 0;
|
||||
-#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -632,7 +672,7 @@ static void color_sycc_to_rgb(opj_image_t *img)
|
||||
{
|
||||
if(img->numcomps < 3)
|
||||
{
|
||||
- img->color_space = CLRSPC_GRAY;
|
||||
+ img->color_space = OPJ_CLRSPC_GRAY;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -658,7 +698,7 @@ static void color_sycc_to_rgb(opj_image_t *img)
|
||||
fprintf(stderr, "%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
- img->color_space = CLRSPC_SRGB;
|
||||
+ img->color_space = OPJ_CLRSPC_SRGB;
|
||||
} /* color_sycc_to_rgb() */
|
||||
|
||||
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
|
||||
diff --git a/src/imageio/format/CMakeLists.txt b/src/imageio/format/CMakeLists.txt
|
||||
index e328cb8..a79f3ee 100644
|
||||
--- a/src/imageio/format/CMakeLists.txt
|
||||
+++ b/src/imageio/format/CMakeLists.txt
|
||||
@@ -22,10 +22,10 @@ if(OPENEXR_FOUND)
|
||||
add_library(exr MODULE "exr.cc")
|
||||
endif(OPENEXR_FOUND)
|
||||
|
||||
-if(OPENJPEG_FOUND)
|
||||
+if(OpenJPEG_FOUND)
|
||||
list(APPEND MODULES "j2k")
|
||||
add_library(j2k MODULE "j2k.c")
|
||||
-endif(OPENJPEG_FOUND)
|
||||
+endif(OpenJPEG_FOUND)
|
||||
|
||||
foreach(module ${MODULES})
|
||||
target_link_libraries(${module} ${LIBS})
|
||||
diff --git a/src/imageio/format/j2k.c b/src/imageio/format/j2k.c
|
||||
index 0344b75..44a995c 100644
|
||||
--- a/src/imageio/format/j2k.c
|
||||
+++ b/src/imageio/format/j2k.c
|
||||
@@ -63,11 +63,6 @@
|
||||
|
||||
#include <openjpeg.h>
|
||||
|
||||
-#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
|
||||
-#define CINEMA_48_CS 651041 /*Codestream length for 48fps*/
|
||||
-#define COMP_24_CS 1041666 /*Maximum size per color component for 2K & 4K @ 24fps*/
|
||||
-#define COMP_48_CS 520833 /*Maximum size per color component for 2K @ 48fps*/
|
||||
-
|
||||
typedef enum
|
||||
{
|
||||
J2K_CFMT = 0,
|
||||
@@ -168,14 +163,14 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres)
|
||||
POC[0].layno1 = 1;
|
||||
POC[0].resno1 = numres - 1;
|
||||
POC[0].compno1 = 3;
|
||||
- POC[0].prg1 = CPRL;
|
||||
+ POC[0].prg1 = OPJ_CPRL;
|
||||
POC[1].tile = 1;
|
||||
POC[1].resno0 = numres - 1;
|
||||
POC[1].compno0 = 0;
|
||||
POC[1].layno1 = 1;
|
||||
POC[1].resno1 = numres;
|
||||
POC[1].compno1 = 3;
|
||||
- POC[1].prg1 = CPRL;
|
||||
+ POC[1].prg1 = OPJ_CPRL;
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -201,7 +196,7 @@ static void cinema_parameters(opj_cparameters_t *parameters)
|
||||
parameters->csty |= 0x01;
|
||||
|
||||
/*The progression order shall be CPRL*/
|
||||
- parameters->prog_order = CPRL;
|
||||
+ parameters->prog_order = OPJ_CPRL;
|
||||
|
||||
/* No ROI */
|
||||
parameters->roi_compno = -1;
|
||||
@@ -220,9 +215,9 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
|
||||
|
||||
switch(parameters->cp_cinema)
|
||||
{
|
||||
- case CINEMA2K_24:
|
||||
- case CINEMA2K_48:
|
||||
- parameters->cp_rsiz = CINEMA2K;
|
||||
+ case OPJ_CINEMA2K_24:
|
||||
+ case OPJ_CINEMA2K_48:
|
||||
+ parameters->cp_rsiz = OPJ_CINEMA2K;
|
||||
if(parameters->numresolution > 6)
|
||||
{
|
||||
parameters->numresolution = 6;
|
||||
@@ -233,12 +228,12 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
|
||||
"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
|
||||
"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
|
||||
image->comps[0].w, image->comps[0].h);
|
||||
- parameters->cp_rsiz = STD_RSIZ;
|
||||
+ parameters->cp_rsiz = OPJ_STD_RSIZ;
|
||||
}
|
||||
break;
|
||||
|
||||
- case CINEMA4K_24:
|
||||
- parameters->cp_rsiz = CINEMA4K;
|
||||
+ case OPJ_CINEMA4K_24:
|
||||
+ parameters->cp_rsiz = OPJ_CINEMA4K;
|
||||
if(parameters->numresolution < 1)
|
||||
{
|
||||
parameters->numresolution = 1;
|
||||
@@ -253,7 +248,7 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
|
||||
"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
|
||||
"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
|
||||
image->comps[0].w, image->comps[0].h);
|
||||
- parameters->cp_rsiz = STD_RSIZ;
|
||||
+ parameters->cp_rsiz = OPJ_STD_RSIZ;
|
||||
}
|
||||
parameters->numpocs = initialise_4K_poc(parameters->POC, parameters->numresolution);
|
||||
break;
|
||||
@@ -263,26 +258,26 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
|
||||
|
||||
switch(parameters->cp_cinema)
|
||||
{
|
||||
- case CINEMA2K_24:
|
||||
- case CINEMA4K_24:
|
||||
+ case OPJ_CINEMA2K_24:
|
||||
+ case OPJ_CINEMA4K_24:
|
||||
for(i = 0; i < parameters->tcp_numlayers; i++)
|
||||
{
|
||||
if(rates[i] == 0)
|
||||
{
|
||||
parameters->tcp_rates[0]
|
||||
= ((float)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))
|
||||
- / (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
+ / (OPJ_CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp_rate
|
||||
= ((float)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))
|
||||
/ (rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
- if(temp_rate > CINEMA_24_CS)
|
||||
+ if(temp_rate > OPJ_CINEMA_24_CS)
|
||||
{
|
||||
parameters->tcp_rates[i]
|
||||
= ((float)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))
|
||||
- / (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
+ / (OPJ_CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -290,28 +285,28 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
|
||||
}
|
||||
}
|
||||
}
|
||||
- parameters->max_comp_size = COMP_24_CS;
|
||||
+ parameters->max_comp_size = OPJ_CINEMA_24_COMP;
|
||||
break;
|
||||
|
||||
- case CINEMA2K_48:
|
||||
+ case OPJ_CINEMA2K_48:
|
||||
for(i = 0; i < parameters->tcp_numlayers; i++)
|
||||
{
|
||||
if(rates[i] == 0)
|
||||
{
|
||||
parameters->tcp_rates[0]
|
||||
= ((float)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))
|
||||
- / (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
+ / (OPJ_CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp_rate
|
||||
= ((float)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))
|
||||
/ (rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
- if(temp_rate > CINEMA_48_CS)
|
||||
+ if(temp_rate > OPJ_CINEMA_48_CS)
|
||||
{
|
||||
parameters->tcp_rates[0]
|
||||
= ((float)(image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))
|
||||
- / (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
+ / (OPJ_CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -319,7 +314,7 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, opj_image_t *ima
|
||||
}
|
||||
}
|
||||
}
|
||||
- parameters->max_comp_size = COMP_48_CS;
|
||||
+ parameters->max_comp_size = OPJ_CINEMA_48_COMP;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -334,19 +329,9 @@ int write_image(dt_imageio_module_data_t *j2k_tmp, const char *filename, const v
|
||||
dt_imageio_j2k_t *j2k = (dt_imageio_j2k_t *)j2k_tmp;
|
||||
opj_cparameters_t parameters; /* compression parameters */
|
||||
float *rates = NULL;
|
||||
- opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
const int quality = CLAMP(j2k->quality, 1, 100);
|
||||
|
||||
- /*
|
||||
- configure the event callbacks (not required)
|
||||
- setting of each callback is optional
|
||||
- */
|
||||
- memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
- event_mgr.error_handler = error_callback;
|
||||
- event_mgr.warning_handler = warning_callback;
|
||||
- event_mgr.info_handler = info_callback;
|
||||
-
|
||||
/* set encoding parameters to default values */
|
||||
opj_set_default_encoder_parameters(¶meters);
|
||||
|
||||
@@ -357,7 +342,7 @@ int write_image(dt_imageio_module_data_t *j2k_tmp, const char *filename, const v
|
||||
|
||||
parameters.tcp_numlayers = 1; /* only one resolution */
|
||||
parameters.cp_disto_alloc = 1;
|
||||
- parameters.cp_rsiz = STD_RSIZ;
|
||||
+ parameters.cp_rsiz = OPJ_STD_RSIZ;
|
||||
|
||||
parameters.cod_format = j2k->format;
|
||||
parameters.cp_cinema = (OPJ_CINEMA_MODE)j2k->preset;
|
||||
@@ -397,7 +382,7 @@ int write_image(dt_imageio_module_data_t *j2k_tmp, const char *filename, const v
|
||||
cmptparm[i].w = w;
|
||||
cmptparm[i].h = h;
|
||||
}
|
||||
- image = opj_image_create(numcomps, &cmptparm[0], CLRSPC_SRGB);
|
||||
+ image = opj_image_create(numcomps, &cmptparm[0], OPJ_CLRSPC_SRGB);
|
||||
if(!image)
|
||||
{
|
||||
fprintf(stderr, "Error: opj_image_create() failed\n");
|
||||
@@ -437,6 +422,7 @@ int write_image(dt_imageio_module_data_t *j2k_tmp, const char *filename, const v
|
||||
fprintf(stderr, "Error: this shouldn't happen, there is no bit depth of %d for jpeg 2000 images.\n",
|
||||
prec);
|
||||
free(rates);
|
||||
+ opj_image_destroy(image);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -457,58 +443,66 @@ int write_image(dt_imageio_module_data_t *j2k_tmp, const char *filename, const v
|
||||
int rc = 1;
|
||||
OPJ_CODEC_FORMAT codec;
|
||||
if(parameters.cod_format == J2K_CFMT) /* J2K format output */
|
||||
- codec = CODEC_J2K;
|
||||
+ codec = OPJ_CODEC_J2K;
|
||||
else
|
||||
- codec = CODEC_JP2;
|
||||
+ codec = OPJ_CODEC_JP2;
|
||||
|
||||
- int codestream_length;
|
||||
- size_t res;
|
||||
- opj_cio_t *cio = NULL;
|
||||
- FILE *f = NULL;
|
||||
+ opj_stream_t *cstream = NULL;
|
||||
|
||||
/* get a J2K/JP2 compressor handle */
|
||||
- opj_cinfo_t *cinfo = opj_create_compress(codec);
|
||||
+ opj_codec_t *ccodec = opj_create_compress(codec);
|
||||
+
|
||||
+ opj_set_error_handler(ccodec, error_callback, stderr);
|
||||
+ opj_set_warning_handler(ccodec, warning_callback, stderr);
|
||||
+ opj_set_info_handler(ccodec, info_callback, stderr);
|
||||
|
||||
- /* catch events using our callbacks and give a local context */
|
||||
- opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||
+ g_strlcpy(parameters.outfile, filename, sizeof(parameters.outfile));
|
||||
|
||||
/* setup the encoder parameters using the current image and user parameters */
|
||||
- opj_setup_encoder(cinfo, ¶meters, image);
|
||||
+ opj_setup_encoder(ccodec, ¶meters, image);
|
||||
|
||||
/* open a byte stream for writing */
|
||||
/* allocate memory for all tiles */
|
||||
- cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
||||
-
|
||||
- /* encode the image */
|
||||
- if(!opj_encode(cinfo, cio, image, NULL))
|
||||
+ cstream = opj_stream_create_default_file_stream(parameters.outfile, OPJ_FALSE);
|
||||
+ if(!cstream)
|
||||
{
|
||||
- opj_cio_close(cio);
|
||||
- fprintf(stderr, "failed to encode image\n");
|
||||
+ opj_destroy_codec(ccodec);
|
||||
+ opj_image_destroy(image);
|
||||
+ fprintf(stderr, "failed to create output stream\n");
|
||||
return 1;
|
||||
}
|
||||
- codestream_length = cio_tell(cio);
|
||||
|
||||
- /* write the buffer to disk */
|
||||
- f = fopen(filename, "wb");
|
||||
- if(!f)
|
||||
+ if(!opj_start_compress(ccodec, image, cstream))
|
||||
{
|
||||
- fprintf(stderr, "failed to open %s for writing\n", filename);
|
||||
+ opj_stream_destroy(cstream);
|
||||
+ opj_destroy_codec(ccodec);
|
||||
+ opj_image_destroy(image);
|
||||
+ fprintf(stderr, "failed to encode image: opj_start_compress\n");
|
||||
return 1;
|
||||
}
|
||||
- res = fwrite(cio->buffer, 1, codestream_length, f);
|
||||
- if(res < (size_t)codestream_length) /* FIXME */
|
||||
+
|
||||
+ /* encode the image */
|
||||
+ if(!opj_encode(ccodec, cstream))
|
||||
{
|
||||
- fprintf(stderr, "failed to write %d (%s)\n", codestream_length, filename);
|
||||
- fclose(f);
|
||||
+ opj_stream_destroy(cstream);
|
||||
+ opj_destroy_codec(ccodec);
|
||||
+ opj_image_destroy(image);
|
||||
+ fprintf(stderr, "failed to encode image: opj_encode\n");
|
||||
return 1;
|
||||
}
|
||||
- fclose(f);
|
||||
|
||||
- /* close and free the byte stream */
|
||||
- opj_cio_close(cio);
|
||||
+ /* encode the image */
|
||||
+ if(!opj_end_compress(ccodec, cstream))
|
||||
+ {
|
||||
+ opj_stream_destroy(cstream);
|
||||
+ opj_destroy_codec(ccodec);
|
||||
+ opj_image_destroy(image);
|
||||
+ fprintf(stderr, "failed to encode image: opj_end_compress\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
|
||||
- /* free remaining compression structures */
|
||||
- opj_destroy_compress(cinfo);
|
||||
+ opj_stream_destroy(cstream);
|
||||
+ opj_destroy_codec(ccodec);
|
||||
|
||||
/* add exif data blob. seems to not work for j2k files :( */
|
||||
if(exif && j2k->format == JP2_CFMT) rc = dt_exif_write_blob(exif, exif_len, filename, 1);
|
||||
-348
@@ -1,348 +0,0 @@
|
||||
From c508a40d9b3fb0e113b0d2618c71b744c715899d Mon Sep 17 00:00:00 2001
|
||||
From: Roman Lebedev <lebedev.ri@gmail.com>
|
||||
Date: Thu, 9 Jun 2016 12:50:02 +0300
|
||||
Subject: [PATCH 2/3] CMake modules: update our copy of LibFindMacros.
|
||||
|
||||
(cherry picked from commit 7bd5417fd20308b0334dfd4bf96a71f6361ae3e4)
|
||||
---
|
||||
cmake/modules/LibFindMacros.cmake | 324 ++++++++++++++++++++++++++++++--------
|
||||
1 file changed, 257 insertions(+), 67 deletions(-)
|
||||
|
||||
diff --git a/cmake/modules/LibFindMacros.cmake b/cmake/modules/LibFindMacros.cmake
|
||||
index 5a83443..1e29796 100644
|
||||
--- a/cmake/modules/LibFindMacros.cmake
|
||||
+++ b/cmake/modules/LibFindMacros.cmake
|
||||
@@ -1,30 +1,97 @@
|
||||
-# Works the same as find_package, but forwards the "REQUIRED" argument used for
|
||||
-# the current package and always uses the "QUIET" flag. For this to work, the
|
||||
-# first parameter must be the prefix of the current package, then the prefix of
|
||||
-# the new package etc, which are passed to find_package.
|
||||
-macro (libfind_package PREFIX)
|
||||
- set (LIBFIND_PACKAGE_ARGS ${ARGN} QUIET)
|
||||
+# Version 2.2
|
||||
+# Public Domain, originally written by Lasse Kärkkäinen <tronic>
|
||||
+# Maintained at https://github.com/Tronic/cmake-modules
|
||||
+# Please send your improvements as pull requests on Github.
|
||||
+
|
||||
+# Find another package and make it a dependency of the current package.
|
||||
+# This also automatically forwards the "REQUIRED" argument.
|
||||
+# Usage: libfind_package(<prefix> <another package> [extra args to find_package])
|
||||
+macro (libfind_package PREFIX PKG)
|
||||
+ set(${PREFIX}_args ${PKG} ${ARGN})
|
||||
if (${PREFIX}_FIND_REQUIRED)
|
||||
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
|
||||
- endif (${PREFIX}_FIND_REQUIRED)
|
||||
- find_package(${LIBFIND_PACKAGE_ARGS})
|
||||
-endmacro (libfind_package)
|
||||
-
|
||||
-# Damn CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
|
||||
-# where they added pkg_check_modules. Consequently I need to support both in my scripts
|
||||
-# to avoid those deprecated warnings. Here's a helper that does just that.
|
||||
-# Works identically to pkg_check_modules, except that no checks are needed prior to use.
|
||||
-macro (libfind_pkg_check_modules PREFIX PKGNAME)
|
||||
- if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
|
||||
- include(UsePkgConfig)
|
||||
- pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
|
||||
- else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
|
||||
- find_package(PkgConfig)
|
||||
- if (PKG_CONFIG_FOUND)
|
||||
- pkg_check_modules(${PREFIX} ${PKGNAME})
|
||||
- endif (PKG_CONFIG_FOUND)
|
||||
- endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
|
||||
-endmacro (libfind_pkg_check_modules)
|
||||
+ set(${PREFIX}_args ${${PREFIX}_args} REQUIRED)
|
||||
+ endif()
|
||||
+ find_package(${${PREFIX}_args})
|
||||
+ set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG})
|
||||
+ unset(${PREFIX}_args)
|
||||
+endmacro()
|
||||
+
|
||||
+# A simple wrapper to make pkg-config searches a bit easier.
|
||||
+# Works the same as CMake's internal pkg_check_modules but is always quiet.
|
||||
+macro (libfind_pkg_check_modules)
|
||||
+ find_package(PkgConfig QUIET)
|
||||
+ if (PKG_CONFIG_FOUND)
|
||||
+ pkg_check_modules(${ARGN} QUIET)
|
||||
+ endif()
|
||||
+endmacro()
|
||||
+
|
||||
+# Avoid useless copy&pasta by doing what most simple libraries do anyway:
|
||||
+# pkg-config, find headers, find library.
|
||||
+# Usage: libfind_pkg_detect(<prefix> <pkg-config args> FIND_PATH <name> [other args] FIND_LIBRARY <name> [other args])
|
||||
+# E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2)
|
||||
+function (libfind_pkg_detect PREFIX)
|
||||
+ # Parse arguments
|
||||
+ set(argname pkgargs)
|
||||
+ foreach (i ${ARGN})
|
||||
+ if ("${i}" STREQUAL "FIND_PATH")
|
||||
+ set(argname pathargs)
|
||||
+ elseif ("${i}" STREQUAL "FIND_LIBRARY")
|
||||
+ set(argname libraryargs)
|
||||
+ else()
|
||||
+ set(${argname} ${${argname}} ${i})
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+ if (NOT pkgargs)
|
||||
+ message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.")
|
||||
+ endif()
|
||||
+ # Find library
|
||||
+ libfind_pkg_check_modules(${PREFIX}_PKGCONF ${pkgargs})
|
||||
+ if (pathargs)
|
||||
+ find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS})
|
||||
+ endif()
|
||||
+ if (libraryargs)
|
||||
+ find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
|
||||
+ endif()
|
||||
+endfunction()
|
||||
+
|
||||
+# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
|
||||
+# Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR)
|
||||
+# Fourth argument "QUIET" may be used for silently testing different define names.
|
||||
+# This function does nothing if the version variable is already defined.
|
||||
+function (libfind_version_header PREFIX VERSION_H DEFINE_NAME)
|
||||
+ # Skip processing if we already have a version or if the include dir was not found
|
||||
+ if (${PREFIX}_VERSION OR NOT ${PREFIX}_INCLUDE_DIR)
|
||||
+ return()
|
||||
+ endif()
|
||||
+ set(quiet ${${PREFIX}_FIND_QUIETLY})
|
||||
+ # Process optional arguments
|
||||
+ foreach(arg ${ARGN})
|
||||
+ if (arg STREQUAL "QUIET")
|
||||
+ set(quiet TRUE)
|
||||
+ else()
|
||||
+ message(AUTHOR_WARNING "Unknown argument ${arg} to libfind_version_header ignored.")
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+ # Read the header and parse for version number
|
||||
+ set(filename "${${PREFIX}_INCLUDE_DIR}/${VERSION_H}")
|
||||
+ if (NOT EXISTS ${filename})
|
||||
+ if (NOT quiet)
|
||||
+ message(AUTHOR_WARNING "Unable to find ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}")
|
||||
+ endif()
|
||||
+ return()
|
||||
+ endif()
|
||||
+ file(READ "${filename}" header)
|
||||
+ string(REGEX REPLACE ".*#[ \t]*define[ \t]*${DEFINE_NAME}[ \t]*\"([^\n]*)\".*" "\\1" match "${header}")
|
||||
+ # No regex match?
|
||||
+ if (match STREQUAL header)
|
||||
+ if (NOT quiet)
|
||||
+ message(AUTHOR_WARNING "Unable to find \#define ${DEFINE_NAME} \"<version>\" from ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}")
|
||||
+ endif()
|
||||
+ return()
|
||||
+ endif()
|
||||
+ # Export the version string
|
||||
+ set(${PREFIX}_VERSION "${match}" PARENT_SCOPE)
|
||||
+endfunction()
|
||||
|
||||
# Do the final processing once the paths have been detected.
|
||||
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
|
||||
@@ -32,45 +99,168 @@ endmacro (libfind_pkg_check_modules)
|
||||
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
|
||||
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
|
||||
# Also handles errors in case library detection was required, etc.
|
||||
-macro (libfind_process PREFIX)
|
||||
- # Skip processing if already processed during this run
|
||||
- if (NOT ${PREFIX}_FOUND)
|
||||
- # Start with the assumption that the library was found
|
||||
- set (${PREFIX}_FOUND TRUE)
|
||||
-
|
||||
- # Process all includes and set _FOUND to false if any are missing
|
||||
- foreach (i ${${PREFIX}_PROCESS_INCLUDES})
|
||||
- if (i)
|
||||
- set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
|
||||
- mark_as_advanced(${i})
|
||||
- else (i)
|
||||
- set (${PREFIX}_FOUND FALSE)
|
||||
- endif (i)
|
||||
- endforeach (i)
|
||||
-
|
||||
- # Process all libraries and set _FOUND to false if any are missing
|
||||
- foreach (i ${${PREFIX}_PROCESS_LIBS})
|
||||
- if (i)
|
||||
- set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
|
||||
- mark_as_advanced(${i})
|
||||
- else (i)
|
||||
- set (${PREFIX}_FOUND FALSE)
|
||||
- endif (i)
|
||||
- endforeach (i)
|
||||
-
|
||||
- # Print message and/or exit on fatal error
|
||||
- if (${PREFIX}_FOUND)
|
||||
- if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
- message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
|
||||
- endif (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
- else (${PREFIX}_FOUND)
|
||||
- if (${PREFIX}_FIND_REQUIRED)
|
||||
- foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
|
||||
- message("${i}=${${i}}")
|
||||
- endforeach (i)
|
||||
- message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
|
||||
- endif (${PREFIX}_FIND_REQUIRED)
|
||||
- endif (${PREFIX}_FOUND)
|
||||
- endif (NOT ${PREFIX}_FOUND)
|
||||
-endmacro (libfind_process)
|
||||
+function (libfind_process PREFIX)
|
||||
+ # Skip processing if already processed during this configuration run
|
||||
+ if (${PREFIX}_FOUND)
|
||||
+ return()
|
||||
+ endif()
|
||||
+
|
||||
+ set(found TRUE) # Start with the assumption that the package was found
|
||||
+
|
||||
+ # Did we find any files? Did we miss includes? These are for formatting better error messages.
|
||||
+ set(some_files FALSE)
|
||||
+ set(missing_headers FALSE)
|
||||
+
|
||||
+ # Shorthands for some variables that we need often
|
||||
+ set(quiet ${${PREFIX}_FIND_QUIETLY})
|
||||
+ set(required ${${PREFIX}_FIND_REQUIRED})
|
||||
+ set(exactver ${${PREFIX}_FIND_VERSION_EXACT})
|
||||
+ set(findver "${${PREFIX}_FIND_VERSION}")
|
||||
+ set(version "${${PREFIX}_VERSION}")
|
||||
+
|
||||
+ # Lists of config option names (all, includes, libs)
|
||||
+ unset(configopts)
|
||||
+ set(includeopts ${${PREFIX}_PROCESS_INCLUDES})
|
||||
+ set(libraryopts ${${PREFIX}_PROCESS_LIBS})
|
||||
+
|
||||
+ # Process deps to add to
|
||||
+ foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
|
||||
+ if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
|
||||
+ # The package seems to export option lists that we can use, woohoo!
|
||||
+ list(APPEND includeopts ${${i}_INCLUDE_OPTS})
|
||||
+ list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
|
||||
+ else()
|
||||
+ # If plural forms don't exist or they equal singular forms
|
||||
+ if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
|
||||
+ ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
|
||||
+ # Singular forms can be used
|
||||
+ if (DEFINED ${i}_INCLUDE_DIR)
|
||||
+ list(APPEND includeopts ${i}_INCLUDE_DIR)
|
||||
+ endif()
|
||||
+ if (DEFINED ${i}_LIBRARY)
|
||||
+ list(APPEND libraryopts ${i}_LIBRARY)
|
||||
+ endif()
|
||||
+ else()
|
||||
+ # Oh no, we don't know the option names
|
||||
+ message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
|
||||
+ endif()
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+
|
||||
+ if (includeopts)
|
||||
+ list(REMOVE_DUPLICATES includeopts)
|
||||
+ endif()
|
||||
+
|
||||
+ if (libraryopts)
|
||||
+ list(REMOVE_DUPLICATES libraryopts)
|
||||
+ endif()
|
||||
+
|
||||
+ string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}")
|
||||
+ if (NOT tmp STREQUAL "${includeopts} ${libraryopts}")
|
||||
+ message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).")
|
||||
+ endif()
|
||||
+
|
||||
+ # Include/library names separated by spaces (notice: not CMake lists)
|
||||
+ unset(includes)
|
||||
+ unset(libs)
|
||||
+
|
||||
+ # Process all includes and set found false if any are missing
|
||||
+ foreach (i ${includeopts})
|
||||
+ list(APPEND configopts ${i})
|
||||
+ if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND")
|
||||
+ list(APPEND includes "${${i}}")
|
||||
+ else()
|
||||
+ set(found FALSE)
|
||||
+ set(missing_headers TRUE)
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+
|
||||
+ # Process all libraries and set found false if any are missing
|
||||
+ foreach (i ${libraryopts})
|
||||
+ list(APPEND configopts ${i})
|
||||
+ if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND")
|
||||
+ list(APPEND libs "${${i}}")
|
||||
+ else()
|
||||
+ set (found FALSE)
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+
|
||||
+ # Version checks
|
||||
+ if (found AND findver)
|
||||
+ if (NOT version)
|
||||
+ message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.")
|
||||
+ elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver))
|
||||
+ set(found FALSE)
|
||||
+ set(version_unsuitable TRUE)
|
||||
+ endif()
|
||||
+ endif()
|
||||
+
|
||||
+ # If all-OK, hide all config options, export variables, print status and exit
|
||||
+ if (found)
|
||||
+ foreach (i ${configopts})
|
||||
+ mark_as_advanced(${i})
|
||||
+ endforeach()
|
||||
+ if (NOT quiet)
|
||||
+ message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
|
||||
+ if (LIBFIND_DEBUG)
|
||||
+ message(STATUS " ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}")
|
||||
+ message(STATUS " ${PREFIX}_INCLUDE_OPTS=${includeopts}")
|
||||
+ message(STATUS " ${PREFIX}_INCLUDE_DIRS=${includes}")
|
||||
+ message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
|
||||
+ message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
|
||||
+ endif()
|
||||
+ set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
|
||||
+ set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
|
||||
+ set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
|
||||
+ set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
|
||||
+ set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
|
||||
+ endif()
|
||||
+ return()
|
||||
+ endif()
|
||||
+
|
||||
+ # Format messages for debug info and the type of error
|
||||
+ set(vars "Relevant CMake configuration variables:\n")
|
||||
+ foreach (i ${configopts})
|
||||
+ mark_as_advanced(CLEAR ${i})
|
||||
+ set(val ${${i}})
|
||||
+ if ("${val}" STREQUAL "${i}-NOTFOUND")
|
||||
+ set (val "<not found>")
|
||||
+ elseif (val AND NOT EXISTS ${val})
|
||||
+ set (val "${val} (does not exist)")
|
||||
+ else()
|
||||
+ set(some_files TRUE)
|
||||
+ endif()
|
||||
+ set(vars "${vars} ${i}=${val}\n")
|
||||
+ endforeach()
|
||||
+ set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n")
|
||||
+ if (version_unsuitable)
|
||||
+ set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but")
|
||||
+ if (exactver)
|
||||
+ set(msg "${msg} only version ${findver} is acceptable.")
|
||||
+ else()
|
||||
+ set(msg "${msg} version ${findver} is the minimum requirement.")
|
||||
+ endif()
|
||||
+ else()
|
||||
+ if (missing_headers)
|
||||
+ set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?")
|
||||
+ elseif (some_files)
|
||||
+ set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?")
|
||||
+ if(findver)
|
||||
+ set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).")
|
||||
+ endif()
|
||||
+ else()
|
||||
+ set(msg "We were unable to find package ${PREFIX}.")
|
||||
+ endif()
|
||||
+ endif()
|
||||
+
|
||||
+ # Fatal error out if REQUIRED
|
||||
+ if (required)
|
||||
+ set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.")
|
||||
+ message(FATAL_ERROR "${msg}\n${vars}")
|
||||
+ endif()
|
||||
+ # Otherwise just print a nasty warning
|
||||
+ if (NOT quiet)
|
||||
+ message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}")
|
||||
+ endif()
|
||||
+endfunction()
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
From 6f52fa346ef5dd5c22895a5fc404bf02bf29932c Mon Sep 17 00:00:00 2001
|
||||
From: Roman Lebedev <lebedev.ri@gmail.com>
|
||||
Date: Thu, 9 Jun 2016 12:52:09 +0300
|
||||
Subject: [PATCH 3/3] Fix warning in FindGIO.cmake
|
||||
|
||||
CMake Warning (dev) at cmake/modules/LibFindMacros.cmake:160 (message):
|
||||
Plural form Glib_LIBRARIES;Glib_LIBRARY found in config options of GIO.
|
||||
This works as before but is now deprecated. Please only use singular forms
|
||||
INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros >
|
||||
2.0 automatic dependency system (most often you can simply remove the
|
||||
PROCESS variables entirely).
|
||||
Call Stack (most recent call first):
|
||||
cmake/modules/FindGIO.cmake:26 (libfind_process)
|
||||
src/CMakeLists.txt:196 (find_package)
|
||||
|
||||
(cherry picked from commit 0717a2f5fc9dce880376c22856eae0c4dd7e4955)
|
||||
---
|
||||
cmake/modules/FindGIO.cmake | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/cmake/modules/FindGIO.cmake b/cmake/modules/FindGIO.cmake
|
||||
index c039042..a62f36e 100644
|
||||
--- a/cmake/modules/FindGIO.cmake
|
||||
+++ b/cmake/modules/FindGIO.cmake
|
||||
@@ -21,7 +21,5 @@ find_library(GIO_LIBRARY
|
||||
|
||||
# Set the include dir variables and the libraries and let libfind_process do the rest.
|
||||
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
|
||||
-set(GIO_PROCESS_INCLUDES Glib_INCLUDE_DIRS)
|
||||
-set(GIO_PROCESS_LIBS GIO_LIBRARY Glib_LIBRARIES)
|
||||
libfind_process(GIO)
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 6cbeab77d..21cf6b44a 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -329,7 +329,12 @@ if(USE_CAMERA_SUPPORT)
|
||||
endif(USE_CAMERA_SUPPORT)
|
||||
|
||||
if(USE_OPENEXR)
|
||||
- find_package(OpenEXR)
|
||||
+ find_package(OpenEXR 3.0 CONFIG)
|
||||
+ if(TARGET OpenEXR::OpenEXR)
|
||||
+ set(OpenEXR_LIBRARIES OpenEXR::OpenEXR)
|
||||
+ else()
|
||||
+ find_package(OpenEXR)
|
||||
+ endif()
|
||||
if(OpenEXR_FOUND)
|
||||
include_directories(SYSTEM ${OpenEXR_INCLUDE_DIRS})
|
||||
list(APPEND LIBS ${OpenEXR_LIBRARIES})
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
From 8dc68e2a4551f03838b7f2da9276e5d1eb20bca0 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Tutubalin <lexa@lexa.ru>
|
||||
Date: Sun, 25 Jan 2026 19:56:24 +0300
|
||||
Subject: [PATCH] Use LIBRAW_EXCEPTION instead of own internal in
|
||||
losslessjpeg.h
|
||||
|
||||
---
|
||||
internal/losslessjpeg.h | 11 +++--------
|
||||
1 file changed, 3 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/internal/losslessjpeg.h b/internal/losslessjpeg.h
|
||||
index 7964822d..eced82b3 100644
|
||||
--- a/src/external/LibRaw/internal/losslessjpeg.h
|
||||
+++ b/src/external/LibRaw/internal/losslessjpeg.h
|
||||
@@ -20,6 +20,7 @@ it under the terms of the one of two licenses as you choose:
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
+#include "libraw_cxx_defs.h"
|
||||
|
||||
struct BitPump // generic bit source
|
||||
{
|
||||
@@ -37,12 +38,6 @@ struct BitPump // generic bit source
|
||||
|
||||
struct ByteStreamBE // Jpeg is always big endian
|
||||
{
|
||||
- enum Exceptions
|
||||
- {
|
||||
- OK = 0,
|
||||
- EndOfBuffer = 1
|
||||
- };
|
||||
-
|
||||
uint8_t *buffer;
|
||||
unsigned size, pos;
|
||||
ByteStreamBE(uint8_t *b, unsigned s) : buffer(b), size(s), pos(0) {}
|
||||
@@ -52,7 +47,7 @@ struct ByteStreamBE // Jpeg is always big endian
|
||||
uint8_t get_u8()
|
||||
{
|
||||
if (pos >= size)
|
||||
- throw EndOfBuffer;
|
||||
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
|
||||
uint8_t ret = buffer[pos];
|
||||
pos++;
|
||||
return ret;
|
||||
@@ -60,7 +55,7 @@ struct ByteStreamBE // Jpeg is always big endian
|
||||
uint16_t get_u16()
|
||||
{
|
||||
if (pos + 2 > size)
|
||||
- throw EndOfBuffer;
|
||||
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
|
||||
uint8_t r1 = buffer[pos];
|
||||
uint8_t r2 = buffer[pos + 1];
|
||||
pos += 2;
|
||||
@@ -71,7 +71,8 @@
|
||||
</BuildDependencies>
|
||||
<Patches>
|
||||
<Patch level="1">cve-2026-5318.patch</Patch>
|
||||
<Patch level="1">0001-Add-5.4.1-in-appdata.patch</Patch>
|
||||
<Patch level="1">fedora/0001-Add-5.4.1-in-appdata.patch</Patch>
|
||||
<Patch level="1">fedora/8dc68e2a4551f03838b7f2da9276e5d1eb20bca0.patch</Patch>
|
||||
</Patches>
|
||||
</Source>
|
||||
|
||||
@@ -141,7 +142,7 @@
|
||||
|
||||
<History>
|
||||
<Update release="17">
|
||||
<Date>2026-03-03</Date>
|
||||
<Date>2026-05-21</Date>
|
||||
<Version>5.4.1</Version>
|
||||
<Comment>Version bump.</Comment>
|
||||
<Name>Pisi Linux Community</Name>
|
||||
|
||||
Reference in New Issue
Block a user