Compare commits
80 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7113c4e3bb | ||
![]() |
b8197de716 | ||
![]() |
b079198838 | ||
![]() |
110d31891b | ||
![]() |
cc0c71c30b | ||
![]() |
5695ac15ff | ||
![]() |
df5e8628f2 | ||
![]() |
b0c0f0ff04 | ||
![]() |
9afc1699f0 | ||
![]() |
34dae137a9 | ||
![]() |
4d5c5e7c48 | ||
![]() |
fac916f72a | ||
![]() |
8715ce2749 | ||
![]() |
045aa4d9f2 | ||
![]() |
da94042481 | ||
![]() |
31d44f0280 | ||
![]() |
3aaeea7ce8 | ||
![]() |
6e7616c83c | ||
![]() |
9a07ccb3d0 | ||
![]() |
f88c9974e2 | ||
![]() |
0954bc11e3 | ||
![]() |
1e69940955 | ||
![]() |
f66e120452 | ||
![]() |
d6d0f070e1 | ||
![]() |
f1f7c53308 | ||
![]() |
893143c8e1 | ||
![]() |
805972f4c8 | ||
![]() |
45ed017b1b | ||
![]() |
b21a8317e5 | ||
![]() |
5fb81d986e | ||
![]() |
48c16b2c19 | ||
![]() |
ab22c5bad5 | ||
![]() |
ef01f18dfc | ||
![]() |
e078172b1c | ||
![]() |
8750e183c6 | ||
![]() |
6c83f1468c | ||
![]() |
acfb307df4 | ||
![]() |
275aad4df8 | ||
![]() |
734d57d5f7 | ||
![]() |
c16bc057ba | ||
![]() |
ea320dab8b | ||
![]() |
d7e6b7de8a | ||
![]() |
ccd9ced49e | ||
![]() |
9f24b078c7 | ||
![]() |
51155950eb | ||
![]() |
23cee22286 | ||
![]() |
4f9abb9a45 | ||
![]() |
4a2a8693e5 | ||
![]() |
1509ccc51f | ||
![]() |
5bb919a30e | ||
![]() |
54874194a8 | ||
![]() |
d2d35bf6c2 | ||
![]() |
b8bd1b0e07 | ||
![]() |
e40c28c2e8 | ||
![]() |
18da6155b2 | ||
![]() |
b3c422654f | ||
![]() |
9db62b2011 | ||
![]() |
7948d83340 | ||
![]() |
132c4a248b | ||
![]() |
ed294598ea | ||
![]() |
7d3c7a345f | ||
![]() |
69497d35c0 | ||
![]() |
d67cd2220a | ||
![]() |
e3eb0a206d | ||
![]() |
57b216bb58 | ||
![]() |
5fbb8b2645 | ||
![]() |
d4b7f03cfa | ||
![]() |
54179fe1d5 | ||
![]() |
7092f7ea11 | ||
![]() |
107eb31531 | ||
![]() |
8371491a99 | ||
![]() |
956c31d5a6 | ||
![]() |
93f7f90711 | ||
![]() |
1da397e94a | ||
![]() |
31882ad7f4 | ||
![]() |
ba1edf6cd4 | ||
![]() |
23a01dfdef | ||
![]() |
d8fef96f23 | ||
![]() |
c539808d09 | ||
![]() |
426bf8d337 |
@ -8,6 +8,9 @@ matrix:
|
|||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_INCLUDE_IF_DEPLOY=1
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_CI_INCLUDE_IF_DEPLOY=1
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release OPJ_NUM_THREADS=2
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
- Add sanity check for tile coordinates [\#823](https://github.com/uclouvain/openjpeg/pull/823) ([mayeut](https://github.com/mayeut))
|
- Add sanity check for tile coordinates [\#823](https://github.com/uclouvain/openjpeg/pull/823) ([mayeut](https://github.com/mayeut))
|
||||||
- Add test for PR 818 [\#822](https://github.com/uclouvain/openjpeg/pull/822) ([mayeut](https://github.com/mayeut))
|
- Add test for PR 818 [\#822](https://github.com/uclouvain/openjpeg/pull/822) ([mayeut](https://github.com/mayeut))
|
||||||
- Update to libpng 1.6.25 [\#821](https://github.com/uclouvain/openjpeg/pull/821) ([mayeut](https://github.com/mayeut))
|
- Update to libpng 1.6.25 [\#821](https://github.com/uclouvain/openjpeg/pull/821) ([mayeut](https://github.com/mayeut))
|
||||||
- fix incrementing of "l\_tcp-\>m\_nb\_mcc\_records" in opj\_j2k\_read\_mcc [\#820](https://github.com/uclouvain/openjpeg/pull/820) ([mayeut](https://github.com/mayeut))
|
- CVE-2016-8332: fix incrementing of "l\_tcp-\>m\_nb\_mcc\_records" in opj\_j2k\_read\_mcc [\#820](https://github.com/uclouvain/openjpeg/pull/820) ([mayeut](https://github.com/mayeut))
|
||||||
- Add overflow check in opj\_tcd\_init\_tile [\#819](https://github.com/uclouvain/openjpeg/pull/819) ([mayeut](https://github.com/mayeut))
|
- Add overflow check in opj\_tcd\_init\_tile [\#819](https://github.com/uclouvain/openjpeg/pull/819) ([mayeut](https://github.com/mayeut))
|
||||||
- Fix leak & invalid behavior of opj\_jp2\_read\_ihdr [\#818](https://github.com/uclouvain/openjpeg/pull/818) ([mayeut](https://github.com/mayeut))
|
- Fix leak & invalid behavior of opj\_jp2\_read\_ihdr [\#818](https://github.com/uclouvain/openjpeg/pull/818) ([mayeut](https://github.com/mayeut))
|
||||||
- Add overflow check in opj\_j2k\_update\_image\_data [\#817](https://github.com/uclouvain/openjpeg/pull/817) ([mayeut](https://github.com/mayeut))
|
- Add overflow check in opj\_j2k\_update\_image\_data [\#817](https://github.com/uclouvain/openjpeg/pull/817) ([mayeut](https://github.com/mayeut))
|
||||||
|
@ -32,8 +32,8 @@ include_regular_expression("^.*$")
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||||
set(OPENJPEG_VERSION_MAJOR 2)
|
set(OPENJPEG_VERSION_MAJOR 2)
|
||||||
set(OPENJPEG_VERSION_MINOR 1)
|
set(OPENJPEG_VERSION_MINOR 2)
|
||||||
set(OPENJPEG_VERSION_BUILD 2)
|
set(OPENJPEG_VERSION_BUILD 0)
|
||||||
set(OPENJPEG_VERSION
|
set(OPENJPEG_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
set(PACKAGE_VERSION
|
set(PACKAGE_VERSION
|
||||||
@ -54,6 +54,7 @@ set(PACKAGE_VERSION
|
|||||||
# 2.1 | 7
|
# 2.1 | 7
|
||||||
# 2.1.1 | 7
|
# 2.1.1 | 7
|
||||||
# 2.1.2 | 7
|
# 2.1.2 | 7
|
||||||
|
# 2.2.0 | 8
|
||||||
# above is the recommendation by the OPJ team. If you really need to override this default,
|
# above is the recommendation by the OPJ team. If you really need to override this default,
|
||||||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||||
|
@ -73,10 +73,10 @@ API available is the one supported by OpenJPEG.
|
|||||||
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
|
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
|
||||||
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause "Simplified" License"
|
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause "Simplified" License"
|
||||||
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause "Simplified" License"
|
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause "Simplified" License"
|
||||||
[badge-build]: https://travis-ci.org/uclouvain/openjpeg.svg?branch=openjpeg-2.1 "Build Status"
|
[badge-build]: https://travis-ci.org/uclouvain/openjpeg.svg?branch=master "Build Status"
|
||||||
[link-build]: https://travis-ci.org/uclouvain/openjpeg "Build Status"
|
[link-build]: https://travis-ci.org/uclouvain/openjpeg "Build Status"
|
||||||
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=openjpeg-2.1&svg=true "Windows Build Status"
|
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
|
||||||
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/openjpeg-2.1 "Windows Build Status"
|
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
|
||||||
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
|
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"
|
||||||
[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
|
[link-coverity]: https://scan.coverity.com/projects/uclouvain-openjpeg "Coverity Scan Build Status"
|
||||||
[link-api-timeline]: http://www.openjpeg.org/abi-check/timeline/openjpeg "OpenJPEG API/ABI timeline"
|
[link-api-timeline]: http://www.openjpeg.org/abi-check/timeline/openjpeg "OpenJPEG API/ABI timeline"
|
||||||
|
@ -29,6 +29,7 @@ it complete and exempt of errors.
|
|||||||
* Julien Malik
|
* Julien Malik
|
||||||
* Arnaud Maye
|
* Arnaud Maye
|
||||||
* Vincent Nicolas
|
* Vincent Nicolas
|
||||||
|
* Aleksander Nikolic (Cisco Talos)
|
||||||
* Glenn Pearson
|
* Glenn Pearson
|
||||||
* Even Rouault
|
* Even Rouault
|
||||||
* Dzonatas Sol
|
* Dzonatas Sol
|
||||||
|
@ -57,6 +57,9 @@ foreach(exe opj_decompress opj_compress opj_dump)
|
|||||||
# On unix you need to link to the math library:
|
# On unix you need to link to the math library:
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(${exe} m)
|
target_link_libraries(${exe} m)
|
||||||
|
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||||
|
target_link_libraries(${exe} rt)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# Install exe
|
# Install exe
|
||||||
install(TARGETS ${exe}
|
install(TARGETS ${exe}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "windirent.h"
|
#include "windirent.h"
|
||||||
@ -150,6 +151,8 @@ typedef struct opj_decompress_params
|
|||||||
int upsample;
|
int upsample;
|
||||||
/* split output components to different files */
|
/* split output components to different files */
|
||||||
int split_pnm;
|
int split_pnm;
|
||||||
|
/** number of threads */
|
||||||
|
int num_threads;
|
||||||
}opj_decompress_parameters;
|
}opj_decompress_parameters;
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
@ -224,8 +227,11 @@ static void decode_help_display(void) {
|
|||||||
" -upsample\n"
|
" -upsample\n"
|
||||||
" Downsampled components will be upsampled to image size\n"
|
" Downsampled components will be upsampled to image size\n"
|
||||||
" -split-pnm\n"
|
" -split-pnm\n"
|
||||||
" Split output components to different files when writing to PNM\n"
|
" Split output components to different files when writing to PNM\n");
|
||||||
"\n");
|
if( opj_has_thread_support() ) {
|
||||||
|
fprintf(stdout," -threads <num_threads>\n"
|
||||||
|
" Number of threads to use for decoding.\n");
|
||||||
|
}
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
fprintf(stdout," -W <options>\n"
|
fprintf(stdout," -W <options>\n"
|
||||||
@ -520,7 +526,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
|
|||||||
{"OutFor", REQ_ARG, NULL,'O'},
|
{"OutFor", REQ_ARG, NULL,'O'},
|
||||||
{"force-rgb", NO_ARG, NULL, 1},
|
{"force-rgb", NO_ARG, NULL, 1},
|
||||||
{"upsample", NO_ARG, NULL, 1},
|
{"upsample", NO_ARG, NULL, 1},
|
||||||
{"split-pnm", NO_ARG, NULL, 1}
|
{"split-pnm", NO_ARG, NULL, 1},
|
||||||
|
{"threads", REQ_ARG, NULL, 'T'}
|
||||||
};
|
};
|
||||||
|
|
||||||
const char optlist[] = "i:o:r:l:x:d:t:p:"
|
const char optlist[] = "i:o:r:l:x:d:t:p:"
|
||||||
@ -809,6 +816,22 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
|
|||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
case 'T': /* Number of threads */
|
||||||
|
{
|
||||||
|
if( strcmp(opj_optarg, "ALL_CPUS") == 0 )
|
||||||
|
{
|
||||||
|
parameters->num_threads = opj_get_num_cpus();
|
||||||
|
if( parameters->num_threads == 1 )
|
||||||
|
parameters->num_threads = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sscanf(opj_optarg, "%d", ¶meters->num_threads);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -885,8 +908,13 @@ OPJ_FLOAT64 opj_clock(void) {
|
|||||||
/* t is the high resolution performance counter (see MSDN) */
|
/* t is the high resolution performance counter (see MSDN) */
|
||||||
QueryPerformanceCounter ( & t ) ;
|
QueryPerformanceCounter ( & t ) ;
|
||||||
return freq.QuadPart ? (t.QuadPart / (OPJ_FLOAT64)freq.QuadPart) : 0;
|
return freq.QuadPart ? (t.QuadPart / (OPJ_FLOAT64)freq.QuadPart) : 0;
|
||||||
|
#elif defined(__linux)
|
||||||
|
struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
return( (OPJ_FLOAT64)ts.tv_sec + (OPJ_FLOAT64)ts.tv_nsec * 1e-9 );
|
||||||
#else
|
#else
|
||||||
/* Unix or Linux: use resource usage */
|
/* Unix : use resource usage */
|
||||||
|
/* FIXME: this counts the total CPU time, instead of the user perceived time */
|
||||||
struct rusage t;
|
struct rusage t;
|
||||||
OPJ_FLOAT64 procTime;
|
OPJ_FLOAT64 procTime;
|
||||||
/* (1) Get the rusage data structure at this moment (man getrusage) */
|
/* (1) Get the rusage data structure at this moment (man getrusage) */
|
||||||
@ -1307,6 +1335,12 @@ int main(int argc, char **argv)
|
|||||||
failed = 1; goto fin;
|
failed = 1; goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( parameters.num_threads >= 1 && !opj_codec_set_threads(l_codec, parameters.num_threads) ) {
|
||||||
|
fprintf(stderr, "ERROR -> opj_decompress: failed to set number of threads\n");
|
||||||
|
opj_stream_destroy(l_stream);
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
failed = 1; goto fin;
|
||||||
|
}
|
||||||
|
|
||||||
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||||
|
@ -9,6 +9,8 @@ include_directories(
|
|||||||
)
|
)
|
||||||
# Defines the source code for the library
|
# Defines the source code for the library
|
||||||
set(OPENJPEG_SRCS
|
set(OPENJPEG_SRCS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/thread.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/thread.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/bio.c
|
${CMAKE_CURRENT_SOURCE_DIR}/bio.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/bio.h
|
${CMAKE_CURRENT_SOURCE_DIR}/bio.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cio.c
|
${CMAKE_CURRENT_SOURCE_DIR}/cio.c
|
||||||
@ -29,6 +31,7 @@ set(OPENJPEG_SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/mct.h
|
${CMAKE_CURRENT_SOURCE_DIR}/mct.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
|
${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
|
${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mqc_inl.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
|
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
|
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
|
||||||
@ -73,6 +76,11 @@ if(OPJ_DISABLE_TPSOT_FIX)
|
|||||||
add_definitions(-DOPJ_DISABLE_TPSOT_FIX)
|
add_definitions(-DOPJ_DISABLE_TPSOT_FIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Special case for old i586-mingw32msvc-gcc cross compiler
|
||||||
|
if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER MATCHES ".*mingw32msvc.*" )
|
||||||
|
set(WIN32 YES)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Build the library
|
# Build the library
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
@ -121,7 +129,7 @@ endif()
|
|||||||
|
|
||||||
# Experimental option; let's how cppcheck performs
|
# Experimental option; let's how cppcheck performs
|
||||||
# Implementation details:
|
# Implementation details:
|
||||||
# I could not figure out how to easily upload a file to CDash. Instead simply
|
# I could not figure out how to easily upload a file to CDash. Instead simply
|
||||||
# pretend cppcheck is part of the Build step. Technically cppcheck can even
|
# pretend cppcheck is part of the Build step. Technically cppcheck can even
|
||||||
# output gcc formatted error/warning report
|
# output gcc formatted error/warning report
|
||||||
# Another implementation detail: I could not redirect error to the error
|
# Another implementation detail: I could not redirect error to the error
|
||||||
@ -144,3 +152,36 @@ if(OPJ_USE_DSYMUTIL)
|
|||||||
DEPENDS ${OPENJPEG_LIBRARY_NAME})
|
DEPENDS ${OPENJPEG_LIBRARY_NAME})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#################################################################################
|
||||||
|
# threading configuration
|
||||||
|
#################################################################################
|
||||||
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
|
|
||||||
|
option(OPJ_USE_THREAD "Build with thread/mutex support " ON)
|
||||||
|
if(NOT OPJ_USE_THREAD)
|
||||||
|
add_definitions( -DMUTEX_stub)
|
||||||
|
endif(NOT OPJ_USE_THREAD)
|
||||||
|
|
||||||
|
find_package(Threads QUIET)
|
||||||
|
|
||||||
|
if(OPJ_USE_THREAD AND WIN32 AND NOT Threads_FOUND )
|
||||||
|
add_definitions( -DMUTEX_win32)
|
||||||
|
set(Threads_FOUND YES)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT )
|
||||||
|
add_definitions( -DMUTEX_win32)
|
||||||
|
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT )
|
||||||
|
|
||||||
|
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT )
|
||||||
|
add_definitions( -DMUTEX_pthread)
|
||||||
|
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT )
|
||||||
|
|
||||||
|
if(OPJ_USE_THREAD AND NOT Threads_FOUND)
|
||||||
|
message(FATAL_ERROR "No thread library found and thread/mutex support is required by OPJ_USE_THREAD option")
|
||||||
|
endif(OPJ_USE_THREAD AND NOT Threads_FOUND)
|
||||||
|
|
||||||
|
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
||||||
|
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
||||||
|
@ -124,7 +124,7 @@ static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_st
|
|||||||
/**
|
/**
|
||||||
Inverse wavelet transform in 2-D.
|
Inverse wavelet transform in 2-D.
|
||||||
*/
|
*/
|
||||||
static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
|
static OPJ_BOOL opj_dwt_decode_tile(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
|
||||||
|
|
||||||
static OPJ_BOOL opj_dwt_encode_procedure( opj_tcd_tilecomp_t * tilec,
|
static OPJ_BOOL opj_dwt_encode_procedure( opj_tcd_tilecomp_t * tilec,
|
||||||
void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) );
|
void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) );
|
||||||
@ -407,20 +407,17 @@ static INLINE OPJ_BOOL opj_dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void
|
|||||||
l_cur_res = tilec->resolutions + l;
|
l_cur_res = tilec->resolutions + l;
|
||||||
l_last_res = l_cur_res - 1;
|
l_last_res = l_cur_res - 1;
|
||||||
|
|
||||||
l_data_size = opj_dwt_max_resolution(tilec->resolutions, tilec->numresolutions);
|
l_data_size = opj_dwt_max_resolution( tilec->resolutions,tilec->numresolutions);
|
||||||
|
|
||||||
/* overflow check */
|
/* overflow check */
|
||||||
if (l_data_size > (SIZE_MAX / sizeof(OPJ_INT32))) {
|
if (l_data_size > (SIZE_MAX / sizeof(OPJ_INT32))) {
|
||||||
/* FIXME event manager error callback */
|
/* FIXME event manager error callback */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_data_size *= sizeof(OPJ_INT32);
|
l_data_size *= sizeof(OPJ_INT32);
|
||||||
bj = (OPJ_INT32*)opj_malloc(l_data_size);
|
bj = (OPJ_INT32*)opj_malloc(l_data_size);
|
||||||
/* l_data_size is equal to 0 when numresolutions == 1 but bj is not used */
|
/* l_data_size is equal to 0 when numresolutions == 1 but bj is not used */
|
||||||
/* in that case, so do not error out */
|
/* in that case, so do not error out */
|
||||||
if (l_data_size != 0 && ! bj) {
|
if (l_data_size != 0 && ! bj) {
|
||||||
/* FIXME event manager error callback */
|
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
i = l;
|
i = l;
|
||||||
@ -482,8 +479,8 @@ OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec)
|
|||||||
/* <summary> */
|
/* <summary> */
|
||||||
/* Inverse 5-3 wavelet transform in 2-D. */
|
/* Inverse 5-3 wavelet transform in 2-D. */
|
||||||
/* </summary> */
|
/* </summary> */
|
||||||
OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
|
OPJ_BOOL opj_dwt_decode(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
|
||||||
return opj_dwt_decode_tile(tilec, numres, &opj_dwt_decode_1);
|
return opj_dwt_decode_tile(tp, tilec, numres, &opj_dwt_decode_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -565,10 +562,73 @@ static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* OPJ_RESTRICT r, O
|
|||||||
return mr ;
|
return mr ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
opj_dwt_t h;
|
||||||
|
DWT1DFN dwt_1D;
|
||||||
|
OPJ_UINT32 rw;
|
||||||
|
OPJ_UINT32 w;
|
||||||
|
OPJ_INT32 * OPJ_RESTRICT tiledp;
|
||||||
|
OPJ_UINT32 min_j;
|
||||||
|
OPJ_UINT32 max_j;
|
||||||
|
} opj_dwd_decode_h_job_t;
|
||||||
|
|
||||||
|
static void opj_dwt_decode_h_func(void* user_data, opj_tls_t* tls)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 j;
|
||||||
|
opj_dwd_decode_h_job_t* job;
|
||||||
|
(void)tls;
|
||||||
|
|
||||||
|
job = (opj_dwd_decode_h_job_t*)user_data;
|
||||||
|
for( j = job->min_j; j < job->max_j; j++ )
|
||||||
|
{
|
||||||
|
opj_dwt_interleave_h(&job->h, &job->tiledp[j*job->w]);
|
||||||
|
(job->dwt_1D)(&job->h);
|
||||||
|
memcpy(&job->tiledp[j*job->w], job->h.mem, job->rw * sizeof(OPJ_INT32));
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_aligned_free(job->h.mem);
|
||||||
|
opj_free(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
opj_dwt_t v;
|
||||||
|
DWT1DFN dwt_1D;
|
||||||
|
OPJ_UINT32 rh;
|
||||||
|
OPJ_UINT32 w;
|
||||||
|
OPJ_INT32 * OPJ_RESTRICT tiledp;
|
||||||
|
OPJ_UINT32 min_j;
|
||||||
|
OPJ_UINT32 max_j;
|
||||||
|
} opj_dwd_decode_v_job_t;
|
||||||
|
|
||||||
|
static void opj_dwt_decode_v_func(void* user_data, opj_tls_t* tls)
|
||||||
|
{
|
||||||
|
OPJ_UINT32 j;
|
||||||
|
opj_dwd_decode_v_job_t* job;
|
||||||
|
(void)tls;
|
||||||
|
|
||||||
|
job = (opj_dwd_decode_v_job_t*)user_data;
|
||||||
|
for( j = job->min_j; j < job->max_j; j++ )
|
||||||
|
{
|
||||||
|
OPJ_UINT32 k;
|
||||||
|
opj_dwt_interleave_v(&job->v, &job->tiledp[j], (OPJ_INT32)job->w);
|
||||||
|
(job->dwt_1D)(&job->v);
|
||||||
|
for(k = 0; k < job->rh; ++k) {
|
||||||
|
job->tiledp[k * job->w + j] = job->v.mem[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_aligned_free(job->v.mem);
|
||||||
|
opj_free(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* <summary> */
|
/* <summary> */
|
||||||
/* Inverse wavelet transform in 2-D. */
|
/* Inverse wavelet transform in 2-D. */
|
||||||
/* </summary> */
|
/* </summary> */
|
||||||
static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D) {
|
static OPJ_BOOL opj_dwt_decode_tile(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D)
|
||||||
|
{
|
||||||
opj_dwt_t h;
|
opj_dwt_t h;
|
||||||
opj_dwt_t v;
|
opj_dwt_t v;
|
||||||
|
|
||||||
@ -578,23 +638,21 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres
|
|||||||
OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 - tr->y0); /* height of the resolution level computed */
|
OPJ_UINT32 rh = (OPJ_UINT32)(tr->y1 - tr->y0); /* height of the resolution level computed */
|
||||||
|
|
||||||
OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
|
OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
|
||||||
|
size_t h_mem_size;
|
||||||
size_t mr; /* max resolution */
|
int num_threads;
|
||||||
|
|
||||||
if (numres == 1U) {
|
if (numres == 1U) {
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
num_threads = opj_thread_pool_get_thread_count(tp);
|
||||||
mr = opj_dwt_max_resolution(tr, numres);
|
h_mem_size = opj_dwt_max_resolution(tr, numres);
|
||||||
|
|
||||||
/* overflow check */
|
/* overflow check */
|
||||||
if (mr > (SIZE_MAX / sizeof(OPJ_INT32))) {
|
if (h_mem_size > (SIZE_MAX / sizeof(OPJ_INT32))) {
|
||||||
/* FIXME event manager error callback */
|
/* FIXME event manager error callback */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
h_mem_size *= sizeof(OPJ_INT32);
|
||||||
mr *= sizeof(OPJ_INT32);
|
h.mem = (OPJ_INT32*)opj_aligned_malloc(h_mem_size);
|
||||||
h.mem = (OPJ_INT32*)opj_aligned_malloc(mr);
|
|
||||||
if (! h.mem){
|
if (! h.mem){
|
||||||
/* FIXME event manager error callback */
|
/* FIXME event manager error callback */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
@ -616,17 +674,71 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres
|
|||||||
h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
|
h.dn = (OPJ_INT32)(rw - (OPJ_UINT32)h.sn);
|
||||||
h.cas = tr->x0 % 2;
|
h.cas = tr->x0 % 2;
|
||||||
|
|
||||||
|
if( num_threads <= 1 || rh <= 1 )
|
||||||
|
{
|
||||||
for(j = 0; j < rh; ++j) {
|
for(j = 0; j < rh; ++j) {
|
||||||
opj_dwt_interleave_h(&h, &tiledp[j*w]);
|
opj_dwt_interleave_h(&h, &tiledp[j*w]);
|
||||||
(dwt_1D)(&h);
|
(dwt_1D)(&h);
|
||||||
memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
|
memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
|
||||||
|
OPJ_UINT32 step_j;
|
||||||
|
|
||||||
|
if( rh < num_jobs ) {
|
||||||
|
num_jobs = rh;
|
||||||
|
}
|
||||||
|
step_j = (rh / num_jobs);
|
||||||
|
|
||||||
|
for(j = 0; j < num_jobs; j++)
|
||||||
|
{
|
||||||
|
opj_dwd_decode_h_job_t* job;
|
||||||
|
|
||||||
|
job = (opj_dwd_decode_h_job_t*) opj_malloc(sizeof(opj_dwd_decode_h_job_t));
|
||||||
|
if( !job )
|
||||||
|
{
|
||||||
|
/* It would be nice to fallback to single thread case, but */
|
||||||
|
/* unfortunately some jobs may be launched and have modified */
|
||||||
|
/* tiledp, so it is not practical to recover from that error */
|
||||||
|
/* FIXME event manager error callback */
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
opj_aligned_free(h.mem);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
job->h = h;
|
||||||
|
job->dwt_1D = dwt_1D;
|
||||||
|
job->rw = rw;
|
||||||
|
job->w = w;
|
||||||
|
job->tiledp = tiledp;
|
||||||
|
job->min_j = j * step_j;
|
||||||
|
job->max_j = (j + 1U) * step_j; /* this can overflow */
|
||||||
|
if( j == (num_jobs - 1U) ) { /* this will take care of the overflow */
|
||||||
|
job->max_j = rh;
|
||||||
|
}
|
||||||
|
job->h.mem = (OPJ_INT32*)opj_aligned_malloc(h_mem_size);
|
||||||
|
if (!job->h.mem)
|
||||||
|
{
|
||||||
|
/* FIXME event manager error callback */
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
opj_free(job);
|
||||||
|
opj_aligned_free(h.mem);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
opj_thread_pool_submit_job( tp, opj_dwt_decode_h_func, job );
|
||||||
|
}
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
}
|
||||||
|
|
||||||
v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
|
v.dn = (OPJ_INT32)(rh - (OPJ_UINT32)v.sn);
|
||||||
v.cas = tr->y0 % 2;
|
v.cas = tr->y0 % 2;
|
||||||
|
|
||||||
|
if( num_threads <= 1 || rw <= 1 )
|
||||||
|
{
|
||||||
for(j = 0; j < rw; ++j){
|
for(j = 0; j < rw; ++j){
|
||||||
OPJ_UINT32 k;
|
OPJ_UINT32 k;
|
||||||
|
|
||||||
opj_dwt_interleave_v(&v, &tiledp[j], (OPJ_INT32)w);
|
opj_dwt_interleave_v(&v, &tiledp[j], (OPJ_INT32)w);
|
||||||
(dwt_1D)(&v);
|
(dwt_1D)(&v);
|
||||||
for(k = 0; k < rh; ++k) {
|
for(k = 0; k < rh; ++k) {
|
||||||
@ -634,11 +746,61 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPJ_UINT32 num_jobs = (OPJ_UINT32)num_threads;
|
||||||
|
OPJ_UINT32 step_j;
|
||||||
|
|
||||||
|
if( rw < num_jobs ) {
|
||||||
|
num_jobs = rw;
|
||||||
|
}
|
||||||
|
step_j = (rw / num_jobs);
|
||||||
|
|
||||||
|
for( j = 0; j < num_jobs; j++ )
|
||||||
|
{
|
||||||
|
opj_dwd_decode_v_job_t* job;
|
||||||
|
|
||||||
|
job = (opj_dwd_decode_v_job_t*) opj_malloc(sizeof(opj_dwd_decode_v_job_t));
|
||||||
|
if( !job )
|
||||||
|
{
|
||||||
|
/* It would be nice to fallback to single thread case, but */
|
||||||
|
/* unfortunately some jobs may be launched and have modified */
|
||||||
|
/* tiledp, so it is not practical to recover from that error */
|
||||||
|
/* FIXME event manager error callback */
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
opj_aligned_free(v.mem);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
job->v = v;
|
||||||
|
job->dwt_1D = dwt_1D;
|
||||||
|
job->rh = rh;
|
||||||
|
job->w = w;
|
||||||
|
job->tiledp = tiledp;
|
||||||
|
job->min_j = j * step_j;
|
||||||
|
job->max_j = (j + 1U) * step_j; /* this can overflow */
|
||||||
|
if( j == (num_jobs - 1U) ) { /* this will take care of the overflow */
|
||||||
|
job->max_j = rw;
|
||||||
|
}
|
||||||
|
job->v.mem = (OPJ_INT32*)opj_aligned_malloc(h_mem_size);
|
||||||
|
if (!job->v.mem)
|
||||||
|
{
|
||||||
|
/* FIXME event manager error callback */
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
opj_free(job);
|
||||||
|
opj_aligned_free(v.mem);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
opj_thread_pool_submit_job( tp, opj_dwt_decode_v_func, job );
|
||||||
|
}
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
opj_aligned_free(h.mem);
|
opj_aligned_free(h.mem);
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void opj_v4dwt_interleave_h(opj_v4dwt_t* OPJ_RESTRICT w, OPJ_FLOAT32* OPJ_RESTRICT a, OPJ_INT32 x, OPJ_INT32 size){
|
static void opj_v4dwt_interleave_h(opj_v4dwt_t* OPJ_RESTRICT w, OPJ_FLOAT32* OPJ_RESTRICT a, OPJ_INT32 x, OPJ_INT32 size)
|
||||||
|
{
|
||||||
OPJ_FLOAT32* OPJ_RESTRICT bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
|
OPJ_FLOAT32* OPJ_RESTRICT bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
|
||||||
OPJ_INT32 count = w->sn;
|
OPJ_INT32 count = w->sn;
|
||||||
OPJ_INT32 i, k;
|
OPJ_INT32 i, k;
|
||||||
@ -867,24 +1029,21 @@ OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec, OPJ_UINT32
|
|||||||
|
|
||||||
OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
|
OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
|
||||||
|
|
||||||
size_t mr; /* max resolution */
|
size_t l_data_size;
|
||||||
|
|
||||||
mr = opj_dwt_max_resolution(res, numres);
|
|
||||||
|
|
||||||
|
l_data_size = opj_dwt_max_resolution(res, numres);
|
||||||
/* overflow check */
|
/* overflow check */
|
||||||
if (mr > (0xFFFFFFFFU /* UINT32_MAX */ - 5U)) {
|
if (l_data_size > (SIZE_MAX - 5U)) {
|
||||||
/* FIXME event manager error callback */
|
/* FIXME event manager error callback */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
mr += 5U;
|
l_data_size += 5U;
|
||||||
|
/* overflow check */
|
||||||
if (mr > (SIZE_MAX / sizeof(opj_v4_t))) {
|
if (l_data_size > (SIZE_MAX / sizeof(opj_v4_t))) {
|
||||||
/* FIXME event manager error callback */
|
/* FIXME event manager error callback */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
h.wavelet = (opj_v4_t*) opj_aligned_malloc(l_data_size * sizeof(opj_v4_t));
|
||||||
mr *= sizeof(opj_v4_t);
|
|
||||||
h.wavelet = (opj_v4_t*) opj_aligned_malloc(mr);
|
|
||||||
if (!h.wavelet) {
|
if (!h.wavelet) {
|
||||||
/* FIXME event manager error callback */
|
/* FIXME event manager error callback */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
|
@ -63,10 +63,11 @@ OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec);
|
|||||||
/**
|
/**
|
||||||
Inverse 5-3 wavelet transform in 2-D.
|
Inverse 5-3 wavelet transform in 2-D.
|
||||||
Apply a reversible inverse DWT transform to a component of an image.
|
Apply a reversible inverse DWT transform to a component of an image.
|
||||||
|
@param tp Thread pool
|
||||||
@param tilec Tile component information (current tile)
|
@param tilec Tile component information (current tile)
|
||||||
@param numres Number of resolution levels to decode
|
@param numres Number of resolution levels to decode
|
||||||
*/
|
*/
|
||||||
OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres);
|
OPJ_BOOL opj_dwt_decode(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the gain of a subband for the reversible 5-3 DWT.
|
Get the gain of a subband for the reversible 5-3 DWT.
|
||||||
|
@ -5948,6 +5948,35 @@ void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads)
|
||||||
|
{
|
||||||
|
if( opj_has_thread_support() )
|
||||||
|
{
|
||||||
|
opj_thread_pool_destroy(j2k->m_tp);
|
||||||
|
j2k->m_tp = NULL;
|
||||||
|
if (num_threads <= (OPJ_UINT32)INT_MAX ) {
|
||||||
|
j2k->m_tp = opj_thread_pool_create((int)num_threads);
|
||||||
|
}
|
||||||
|
if( j2k->m_tp == NULL )
|
||||||
|
{
|
||||||
|
j2k->m_tp = opj_thread_pool_create(0);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int opj_j2k_get_default_thread_count()
|
||||||
|
{
|
||||||
|
const char* num_threads = getenv("OPJ_NUM_THREADS");
|
||||||
|
if( num_threads == NULL || !opj_has_thread_support() )
|
||||||
|
return 0;
|
||||||
|
if( strcmp(num_threads, "ALL_CPUS") == 0 )
|
||||||
|
return opj_get_num_cpus();
|
||||||
|
return atoi(num_threads);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* J2K encoder interface */
|
/* J2K encoder interface */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
@ -5985,6 +6014,17 @@ opj_j2k_t* opj_j2k_create_compress(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l_j2k->m_tp = opj_thread_pool_create(opj_j2k_get_default_thread_count());
|
||||||
|
if( !l_j2k->m_tp )
|
||||||
|
{
|
||||||
|
l_j2k->m_tp = opj_thread_pool_create(0);
|
||||||
|
}
|
||||||
|
if( !l_j2k->m_tp )
|
||||||
|
{
|
||||||
|
opj_j2k_destroy(l_j2k);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return l_j2k;
|
return l_j2k;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7490,7 +7530,7 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2
|
|||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !opj_tcd_init(p_j2k->m_tcd, l_image, &(p_j2k->m_cp)) ) {
|
if ( !opj_tcd_init(p_j2k->m_tcd, l_image, &(p_j2k->m_cp), p_j2k->m_tp) ) {
|
||||||
opj_tcd_destroy(p_j2k->m_tcd);
|
opj_tcd_destroy(p_j2k->m_tcd);
|
||||||
p_j2k->m_tcd = 00;
|
p_j2k->m_tcd = 00;
|
||||||
opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
|
opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
|
||||||
@ -7571,6 +7611,9 @@ void opj_j2k_destroy (opj_j2k_t *p_j2k)
|
|||||||
opj_image_destroy(p_j2k->m_output_image);
|
opj_image_destroy(p_j2k->m_output_image);
|
||||||
p_j2k->m_output_image = NULL;
|
p_j2k->m_output_image = NULL;
|
||||||
|
|
||||||
|
opj_thread_pool_destroy(p_j2k->m_tp);
|
||||||
|
p_j2k->m_tp = NULL;
|
||||||
|
|
||||||
opj_free(p_j2k);
|
opj_free(p_j2k);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8668,6 +8711,17 @@ opj_j2k_t* opj_j2k_create_decompress(void)
|
|||||||
return 00;
|
return 00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l_j2k->m_tp = opj_thread_pool_create(opj_j2k_get_default_thread_count());
|
||||||
|
if( !l_j2k->m_tp )
|
||||||
|
{
|
||||||
|
l_j2k->m_tp = opj_thread_pool_create(0);
|
||||||
|
}
|
||||||
|
if( !l_j2k->m_tp )
|
||||||
|
{
|
||||||
|
opj_j2k_destroy(l_j2k);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return l_j2k;
|
return l_j2k;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10944,7 +10998,7 @@ static OPJ_BOOL opj_j2k_create_tcd( opj_j2k_t *p_j2k,
|
|||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opj_tcd_init(p_j2k->m_tcd,p_j2k->m_private_image,&p_j2k->m_cp)) {
|
if (!opj_tcd_init(p_j2k->m_tcd,p_j2k->m_private_image,&p_j2k->m_cp, p_j2k->m_tp)) {
|
||||||
opj_tcd_destroy(p_j2k->m_tcd);
|
opj_tcd_destroy(p_j2k->m_tcd);
|
||||||
p_j2k->m_tcd = 00;
|
p_j2k->m_tcd = 00;
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
|
@ -228,7 +228,7 @@ typedef struct opj_simple_mcc_decorrelation_data
|
|||||||
OPJ_UINT32 m_nb_comps;
|
OPJ_UINT32 m_nb_comps;
|
||||||
opj_mct_data_t * m_decorrelation_array;
|
opj_mct_data_t * m_decorrelation_array;
|
||||||
opj_mct_data_t * m_offset_array;
|
opj_mct_data_t * m_offset_array;
|
||||||
OPJ_UINT32 m_is_irreversible : 1;
|
OPJ_BITFIELD m_is_irreversible : 1;
|
||||||
}
|
}
|
||||||
opj_simple_mcc_decorrelation_data_t;
|
opj_simple_mcc_decorrelation_data_t;
|
||||||
|
|
||||||
@ -306,11 +306,11 @@ typedef struct opj_tcp
|
|||||||
|
|
||||||
/***** FLAGS *******/
|
/***** FLAGS *******/
|
||||||
/** If cod == 1 --> there was a COD marker for the present tile */
|
/** If cod == 1 --> there was a COD marker for the present tile */
|
||||||
OPJ_UINT32 cod : 1;
|
OPJ_BITFIELD cod : 1;
|
||||||
/** If ppt == 1 --> there was a PPT marker for the present tile */
|
/** If ppt == 1 --> there was a PPT marker for the present tile */
|
||||||
OPJ_UINT32 ppt : 1;
|
OPJ_BITFIELD ppt : 1;
|
||||||
/** indicates if a POC marker has been used O:NO, 1:YES */
|
/** indicates if a POC marker has been used O:NO, 1:YES */
|
||||||
OPJ_UINT32 POC : 1;
|
OPJ_BITFIELD POC : 1;
|
||||||
} opj_tcp_t;
|
} opj_tcp_t;
|
||||||
|
|
||||||
|
|
||||||
@ -327,13 +327,13 @@ typedef struct opj_encoding_param
|
|||||||
/** Flag determining tile part generation*/
|
/** Flag determining tile part generation*/
|
||||||
OPJ_BYTE m_tp_flag;
|
OPJ_BYTE m_tp_flag;
|
||||||
/** allocation by rate/distortion */
|
/** allocation by rate/distortion */
|
||||||
OPJ_UINT32 m_disto_alloc : 1;
|
OPJ_BITFIELD m_disto_alloc : 1;
|
||||||
/** allocation by fixed layer */
|
/** allocation by fixed layer */
|
||||||
OPJ_UINT32 m_fixed_alloc : 1;
|
OPJ_BITFIELD m_fixed_alloc : 1;
|
||||||
/** add fixed_quality */
|
/** add fixed_quality */
|
||||||
OPJ_UINT32 m_fixed_quality : 1;
|
OPJ_BITFIELD m_fixed_quality : 1;
|
||||||
/** Enabling Tile part generation*/
|
/** Enabling Tile part generation*/
|
||||||
OPJ_UINT32 m_tp_on : 1;
|
OPJ_BITFIELD m_tp_on : 1;
|
||||||
}
|
}
|
||||||
opj_encoding_param_t;
|
opj_encoding_param_t;
|
||||||
|
|
||||||
@ -453,9 +453,9 @@ typedef struct opj_cp
|
|||||||
|
|
||||||
/******** FLAGS *********/
|
/******** FLAGS *********/
|
||||||
/** if ppm == 1 --> there was a PPM marker*/
|
/** if ppm == 1 --> there was a PPM marker*/
|
||||||
OPJ_UINT32 ppm : 1;
|
OPJ_BITFIELD ppm : 1;
|
||||||
/** tells if the parameter is a coding or decoding one */
|
/** tells if the parameter is a coding or decoding one */
|
||||||
OPJ_UINT32 m_is_decoder : 1;
|
OPJ_BITFIELD m_is_decoder : 1;
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
} opj_cp_t;
|
} opj_cp_t;
|
||||||
|
|
||||||
@ -497,12 +497,12 @@ typedef struct opj_j2k_dec
|
|||||||
*/
|
*/
|
||||||
OPJ_BOOL m_last_tile_part;
|
OPJ_BOOL m_last_tile_part;
|
||||||
/** to tell that a tile can be decoded. */
|
/** to tell that a tile can be decoded. */
|
||||||
OPJ_UINT32 m_can_decode : 1;
|
OPJ_BITFIELD m_can_decode : 1;
|
||||||
OPJ_UINT32 m_discard_tiles : 1;
|
OPJ_BITFIELD m_discard_tiles : 1;
|
||||||
OPJ_UINT32 m_skip_data : 1;
|
OPJ_BITFIELD m_skip_data : 1;
|
||||||
/** TNsot correction : see issue 254 **/
|
/** TNsot correction : see issue 254 **/
|
||||||
OPJ_UINT32 m_nb_tile_parts_correction_checked : 1;
|
OPJ_BITFIELD m_nb_tile_parts_correction_checked : 1;
|
||||||
OPJ_UINT32 m_nb_tile_parts_correction : 1;
|
OPJ_BITFIELD m_nb_tile_parts_correction : 1;
|
||||||
|
|
||||||
} opj_j2k_dec_t;
|
} opj_j2k_dec_t;
|
||||||
|
|
||||||
@ -589,6 +589,12 @@ typedef struct opj_j2k
|
|||||||
|
|
||||||
/** the current tile coder/decoder **/
|
/** the current tile coder/decoder **/
|
||||||
struct opj_tcd * m_tcd;
|
struct opj_tcd * m_tcd;
|
||||||
|
|
||||||
|
/** Number of threads to use */
|
||||||
|
int m_num_threads;
|
||||||
|
|
||||||
|
/** Thread pool */
|
||||||
|
opj_thread_pool_t* m_tp;
|
||||||
}
|
}
|
||||||
opj_j2k_t;
|
opj_j2k_t;
|
||||||
|
|
||||||
@ -607,6 +613,8 @@ Decoding parameters are returned in j2k->cp.
|
|||||||
*/
|
*/
|
||||||
void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
|
void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
|
||||||
|
|
||||||
|
OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a J2K compression structure
|
* Creates a J2K compression structure
|
||||||
*
|
*
|
||||||
|
@ -1777,6 +1777,11 @@ void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
|
|||||||
jp2->ignore_pclr_cmap_cdef = parameters->flags & OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
|
jp2->ignore_pclr_cmap_cdef = parameters->flags & OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads)
|
||||||
|
{
|
||||||
|
return opj_j2k_set_threads(jp2->j2k, num_threads);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* JP2 encoder interface */
|
/* JP2 encoder interface */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -243,6 +243,8 @@ Decoding parameters are returned in jp2->j2k->cp.
|
|||||||
*/
|
*/
|
||||||
void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
|
void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
|
||||||
|
|
||||||
|
OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode an image from a JPEG-2000 file stream
|
* Decode an image from a JPEG-2000 file stream
|
||||||
* @param jp2 JP2 decompressor handle
|
* @param jp2 JP2 decompressor handle
|
||||||
|
@ -70,28 +70,6 @@ Fill mqc->c with 1's for flushing
|
|||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
*/
|
*/
|
||||||
static void opj_mqc_setbits(opj_mqc_t *mqc);
|
static void opj_mqc_setbits(opj_mqc_t *mqc);
|
||||||
/**
|
|
||||||
FIXME DOC
|
|
||||||
@param mqc MQC handle
|
|
||||||
@return
|
|
||||||
*/
|
|
||||||
static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc);
|
|
||||||
/**
|
|
||||||
FIXME DOC
|
|
||||||
@param mqc MQC handle
|
|
||||||
@return
|
|
||||||
*/
|
|
||||||
static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc);
|
|
||||||
/**
|
|
||||||
Input a byte
|
|
||||||
@param mqc MQC handle
|
|
||||||
*/
|
|
||||||
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc);
|
|
||||||
/**
|
|
||||||
Renormalize mqc->a and mqc->c while decoding
|
|
||||||
@param mqc MQC handle
|
|
||||||
*/
|
|
||||||
static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc);
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
@ -284,82 +262,6 @@ static void opj_mqc_setbits(opj_mqc_t *mqc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) {
|
|
||||||
OPJ_INT32 d;
|
|
||||||
if (mqc->a < (*mqc->curctx)->qeval) {
|
|
||||||
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
|
|
||||||
*mqc->curctx = (*mqc->curctx)->nlps;
|
|
||||||
} else {
|
|
||||||
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
|
||||||
*mqc->curctx = (*mqc->curctx)->nmps;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) {
|
|
||||||
OPJ_INT32 d;
|
|
||||||
if (mqc->a < (*mqc->curctx)->qeval) {
|
|
||||||
mqc->a = (*mqc->curctx)->qeval;
|
|
||||||
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
|
||||||
*mqc->curctx = (*mqc->curctx)->nmps;
|
|
||||||
} else {
|
|
||||||
mqc->a = (*mqc->curctx)->qeval;
|
|
||||||
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
|
|
||||||
*mqc->curctx = (*mqc->curctx)->nlps;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MQC_PERF_OPT
|
|
||||||
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) {
|
|
||||||
unsigned int i = *((unsigned int *) mqc->bp);
|
|
||||||
mqc->c += i & 0xffff00;
|
|
||||||
mqc->ct = i & 0x0f;
|
|
||||||
mqc->bp += (i >> 2) & 0x04;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static void opj_mqc_bytein(opj_mqc_t *const mqc) {
|
|
||||||
if (mqc->bp != mqc->end) {
|
|
||||||
OPJ_UINT32 c;
|
|
||||||
if (mqc->bp + 1 != mqc->end) {
|
|
||||||
c = *(mqc->bp + 1);
|
|
||||||
} else {
|
|
||||||
c = 0xff;
|
|
||||||
}
|
|
||||||
if (*mqc->bp == 0xff) {
|
|
||||||
if (c > 0x8f) {
|
|
||||||
mqc->c += 0xff00;
|
|
||||||
mqc->ct = 8;
|
|
||||||
} else {
|
|
||||||
mqc->bp++;
|
|
||||||
mqc->c += c << 9;
|
|
||||||
mqc->ct = 7;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mqc->bp++;
|
|
||||||
mqc->c += c << 8;
|
|
||||||
mqc->ct = 8;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mqc->c += 0xff00;
|
|
||||||
mqc->ct = 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) {
|
|
||||||
do {
|
|
||||||
if (mqc->ct == 0) {
|
|
||||||
opj_mqc_bytein(mqc);
|
|
||||||
}
|
|
||||||
mqc->a <<= 1;
|
|
||||||
mqc->c <<= 1;
|
|
||||||
mqc->ct--;
|
|
||||||
} while (mqc->a < 0x8000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==========================================================
|
==========================================================
|
||||||
MQ-Coder interface
|
MQ-Coder interface
|
||||||
@ -585,25 +487,6 @@ OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
|
|||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) {
|
|
||||||
OPJ_INT32 d;
|
|
||||||
mqc->a -= (*mqc->curctx)->qeval;
|
|
||||||
if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
|
|
||||||
d = opj_mqc_lpsexchange(mqc);
|
|
||||||
opj_mqc_renormd(mqc);
|
|
||||||
} else {
|
|
||||||
mqc->c -= (*mqc->curctx)->qeval << 16;
|
|
||||||
if ((mqc->a & 0x8000) == 0) {
|
|
||||||
d = opj_mqc_mpsexchange(mqc);
|
|
||||||
opj_mqc_renormd(mqc);
|
|
||||||
} else {
|
|
||||||
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void opj_mqc_resetstates(opj_mqc_t *mqc) {
|
void opj_mqc_resetstates(opj_mqc_t *mqc) {
|
||||||
OPJ_UINT32 i;
|
OPJ_UINT32 i;
|
||||||
for (i = 0; i < MQC_NUMCTXS; i++) {
|
for (i = 0; i < MQC_NUMCTXS; i++) {
|
||||||
|
@ -77,11 +77,14 @@ typedef struct opj_mqc {
|
|||||||
OPJ_BYTE *end;
|
OPJ_BYTE *end;
|
||||||
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
|
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
|
||||||
opj_mqc_state_t **curctx;
|
opj_mqc_state_t **curctx;
|
||||||
|
const OPJ_BYTE *lut_ctxno_zc_orient; /* lut_ctxno_zc shifted by 256 * bandno */
|
||||||
#ifdef MQC_PERF_OPT
|
#ifdef MQC_PERF_OPT
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
#endif
|
#endif
|
||||||
} opj_mqc_t;
|
} opj_mqc_t;
|
||||||
|
|
||||||
|
#include "mqc_inl.h"
|
||||||
|
|
||||||
/** @name Exported functions */
|
/** @name Exported functions */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
@ -198,7 +201,7 @@ Decode a symbol
|
|||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
@return Returns the decoded symbol (0 or 1)
|
@return Returns the decoded symbol (0 or 1)
|
||||||
*/
|
*/
|
||||||
OPJ_INT32 opj_mqc_decode(opj_mqc_t * const mqc);
|
static INLINE OPJ_INT32 opj_mqc_decode(opj_mqc_t * const mqc);
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
159
src/lib/openjp2/mqc_inl.h
Normal file
159
src/lib/openjp2/mqc_inl.h
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __MQC_INL_H
|
||||||
|
#define __MQC_INL_H
|
||||||
|
/**
|
||||||
|
FIXME DOC
|
||||||
|
@param mqc MQC handle
|
||||||
|
@return
|
||||||
|
*/
|
||||||
|
static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) {
|
||||||
|
OPJ_INT32 d;
|
||||||
|
if (mqc->a < (*mqc->curctx)->qeval) {
|
||||||
|
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
|
||||||
|
*mqc->curctx = (*mqc->curctx)->nlps;
|
||||||
|
} else {
|
||||||
|
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
||||||
|
*mqc->curctx = (*mqc->curctx)->nmps;
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
FIXME DOC
|
||||||
|
@param mqc MQC handle
|
||||||
|
@return
|
||||||
|
*/
|
||||||
|
static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc) {
|
||||||
|
OPJ_INT32 d;
|
||||||
|
if (mqc->a < (*mqc->curctx)->qeval) {
|
||||||
|
mqc->a = (*mqc->curctx)->qeval;
|
||||||
|
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
||||||
|
*mqc->curctx = (*mqc->curctx)->nmps;
|
||||||
|
} else {
|
||||||
|
mqc->a = (*mqc->curctx)->qeval;
|
||||||
|
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
|
||||||
|
*mqc->curctx = (*mqc->curctx)->nlps;
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Input a byte
|
||||||
|
@param mqc MQC handle
|
||||||
|
*/
|
||||||
|
#ifdef MQC_PERF_OPT
|
||||||
|
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) {
|
||||||
|
unsigned int i = *((unsigned int *) mqc->bp);
|
||||||
|
mqc->c += i & 0xffff00;
|
||||||
|
mqc->ct = i & 0x0f;
|
||||||
|
mqc->bp += (i >> 2) & 0x04;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc) {
|
||||||
|
if (mqc->bp != mqc->end) {
|
||||||
|
OPJ_UINT32 c;
|
||||||
|
if (mqc->bp + 1 != mqc->end) {
|
||||||
|
c = *(mqc->bp + 1);
|
||||||
|
} else {
|
||||||
|
c = 0xff;
|
||||||
|
}
|
||||||
|
if (*mqc->bp == 0xff) {
|
||||||
|
if (c > 0x8f) {
|
||||||
|
mqc->c += 0xff00;
|
||||||
|
mqc->ct = 8;
|
||||||
|
} else {
|
||||||
|
mqc->bp++;
|
||||||
|
mqc->c += c << 9;
|
||||||
|
mqc->ct = 7;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mqc->bp++;
|
||||||
|
mqc->c += c << 8;
|
||||||
|
mqc->ct = 8;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mqc->c += 0xff00;
|
||||||
|
mqc->ct = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
Renormalize mqc->a and mqc->c while decoding
|
||||||
|
@param mqc MQC handle
|
||||||
|
*/
|
||||||
|
static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc) {
|
||||||
|
do {
|
||||||
|
if (mqc->ct == 0) {
|
||||||
|
opj_mqc_bytein(mqc);
|
||||||
|
}
|
||||||
|
mqc->a <<= 1;
|
||||||
|
mqc->c <<= 1;
|
||||||
|
mqc->ct--;
|
||||||
|
} while (mqc->a < 0x8000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Decode a symbol
|
||||||
|
@param mqc MQC handle
|
||||||
|
@return Returns the decoded symbol (0 or 1)
|
||||||
|
*/
|
||||||
|
static INLINE OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc) {
|
||||||
|
OPJ_INT32 d;
|
||||||
|
mqc->a -= (*mqc->curctx)->qeval;
|
||||||
|
if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
|
||||||
|
d = opj_mqc_lpsexchange(mqc);
|
||||||
|
opj_mqc_renormd(mqc);
|
||||||
|
} else {
|
||||||
|
mqc->c -= (*mqc->curctx)->qeval << 16;
|
||||||
|
if ((mqc->a & 0x8000) == 0) {
|
||||||
|
d = opj_mqc_mpsexchange(mqc);
|
||||||
|
opj_mqc_renormd(mqc);
|
||||||
|
} else {
|
||||||
|
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __MQC_INL_H */
|
@ -239,6 +239,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||||||
OPJ_UINT32 res_factor,
|
OPJ_UINT32 res_factor,
|
||||||
struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor;
|
struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor;
|
||||||
|
|
||||||
|
l_codec->opj_set_threads =
|
||||||
|
(OPJ_BOOL (*) ( void * p_codec, OPJ_UINT32 num_threads )) opj_j2k_set_threads;
|
||||||
|
|
||||||
l_codec->m_codec = opj_j2k_create_decompress();
|
l_codec->m_codec = opj_j2k_create_decompress();
|
||||||
|
|
||||||
if (! l_codec->m_codec) {
|
if (! l_codec->m_codec) {
|
||||||
@ -315,6 +318,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||||||
OPJ_UINT32 res_factor,
|
OPJ_UINT32 res_factor,
|
||||||
opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor;
|
opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor;
|
||||||
|
|
||||||
|
l_codec->opj_set_threads =
|
||||||
|
(OPJ_BOOL (*) ( void * p_codec, OPJ_UINT32 num_threads )) opj_jp2_set_threads;
|
||||||
|
|
||||||
l_codec->m_codec = opj_jp2_create(OPJ_TRUE);
|
l_codec->m_codec = opj_jp2_create(OPJ_TRUE);
|
||||||
|
|
||||||
if (! l_codec->m_codec) {
|
if (! l_codec->m_codec) {
|
||||||
@ -354,6 +360,18 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
|
||||||
|
int num_threads)
|
||||||
|
{
|
||||||
|
if (p_codec && (num_threads >= 0)) {
|
||||||
|
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
|
||||||
|
|
||||||
|
return l_codec->opj_set_threads(l_codec->m_codec, (OPJ_UINT32)num_threads);
|
||||||
|
}
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
|
OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
|
||||||
opj_dparameters_t *parameters
|
opj_dparameters_t *parameters
|
||||||
)
|
)
|
||||||
|
@ -1262,6 +1262,25 @@ OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *
|
|||||||
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
|
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
|
||||||
opj_dparameters_t *parameters );
|
opj_dparameters_t *parameters );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates worker threads for the compressor/decompressor.
|
||||||
|
*
|
||||||
|
* By default, only the main thread is used. If this function is not used,
|
||||||
|
* but the OPJ_NUM_THREADS environment variable is set, its value will be
|
||||||
|
* used to initialize the number of threads. The value can be either an integer
|
||||||
|
* number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called,
|
||||||
|
* this function will override the behaviour of the environment variable.
|
||||||
|
*
|
||||||
|
* Note: currently only has effect on the decompressor.
|
||||||
|
*
|
||||||
|
* @param p_codec decompressor handler
|
||||||
|
* @param num_threads number of threads.
|
||||||
|
*
|
||||||
|
* @return OPJ_TRUE if the decoder is correctly set
|
||||||
|
*/
|
||||||
|
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec,
|
||||||
|
int num_threads);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes an image header.
|
* Decodes an image header.
|
||||||
*
|
*
|
||||||
@ -1554,6 +1573,19 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT( opj_cparameters_t *parameters,
|
|||||||
OPJ_INT32 * p_dc_shift,
|
OPJ_INT32 * p_dc_shift,
|
||||||
OPJ_UINT32 pNbComp);
|
OPJ_UINT32 pNbComp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
==========================================================
|
||||||
|
Thread functions
|
||||||
|
==========================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Returns if the library is built with thread support.
|
||||||
|
* OPJ_TRUE if mutex, condition, thread, thread pool are available.
|
||||||
|
*/
|
||||||
|
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void);
|
||||||
|
|
||||||
|
/** Return the number of virtual CPUs */
|
||||||
|
OPJ_API int OPJ_CALLCONV opj_get_num_cpus(void);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -113,6 +113,7 @@ typedef struct opj_codec_private
|
|||||||
OPJ_BOOL (*opj_set_decoded_resolution_factor) ( void * p_codec,
|
OPJ_BOOL (*opj_set_decoded_resolution_factor) ( void * p_codec,
|
||||||
OPJ_UINT32 res_factor,
|
OPJ_UINT32 res_factor,
|
||||||
opj_event_mgr_t * p_manager);
|
opj_event_mgr_t * p_manager);
|
||||||
|
|
||||||
} m_decompression;
|
} m_decompression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,6 +158,9 @@ typedef struct opj_codec_private
|
|||||||
void (*opj_dump_codec) (void * p_codec, OPJ_INT32 info_flag, FILE* output_stream);
|
void (*opj_dump_codec) (void * p_codec, OPJ_INT32 info_flag, FILE* output_stream);
|
||||||
opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec);
|
opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec);
|
||||||
opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec);
|
opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec);
|
||||||
|
|
||||||
|
/** Set number of threads */
|
||||||
|
OPJ_BOOL (*opj_set_threads) ( void * p_codec, OPJ_UINT32 num_threads );
|
||||||
}
|
}
|
||||||
opj_codec_private_t;
|
opj_codec_private_t;
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Use fseeko() and ftello() if they are available since they use
|
Use fseeko() and ftello() if they are available since they use
|
||||||
@ -183,6 +184,9 @@ static INLINE long opj_lrintf(float f) {
|
|||||||
# pragma intrinsic(__emul)
|
# pragma intrinsic(__emul)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Type to use for bit-fields in internal headers */
|
||||||
|
typedef unsigned int OPJ_BITFIELD;
|
||||||
|
|
||||||
#include "opj_inttypes.h"
|
#include "opj_inttypes.h"
|
||||||
#include "opj_clock.h"
|
#include "opj_clock.h"
|
||||||
#include "opj_malloc.h"
|
#include "opj_malloc.h"
|
||||||
@ -191,6 +195,9 @@ static INLINE long opj_lrintf(float f) {
|
|||||||
#include "bio.h"
|
#include "bio.h"
|
||||||
#include "cio.h"
|
#include "cio.h"
|
||||||
|
|
||||||
|
#include "thread.h"
|
||||||
|
#include "tls_keys.h"
|
||||||
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "invert.h"
|
#include "invert.h"
|
||||||
#include "j2k.h"
|
#include "j2k.h"
|
||||||
|
1196
src/lib/openjp2/t1.c
1196
src/lib/openjp2/t1.c
File diff suppressed because it is too large
Load Diff
@ -50,26 +50,30 @@ in T1.C are used by some function in TCD.C.
|
|||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
#define T1_NMSEDEC_BITS 7
|
#define T1_NMSEDEC_BITS 7
|
||||||
|
|
||||||
#define T1_SIG_NE 0x0001 /**< Context orientation : North-East direction */
|
/* CAUTION: the value of those constants must not be changed, otherwise the */
|
||||||
#define T1_SIG_SE 0x0002 /**< Context orientation : South-East direction */
|
/* optimization of opj_t1_updateflags() will break! */
|
||||||
#define T1_SIG_SW 0x0004 /**< Context orientation : South-West direction */
|
/* BEGINNING of flags that apply to opj_flag_t */
|
||||||
#define T1_SIG_NW 0x0008 /**< Context orientation : North-West direction */
|
#define T1_SIG_NE 0x0001U /**< Context orientation : North-East direction */
|
||||||
#define T1_SIG_N 0x0010 /**< Context orientation : North direction */
|
#define T1_SIG_SE 0x0002U /**< Context orientation : South-East direction */
|
||||||
#define T1_SIG_E 0x0020 /**< Context orientation : East direction */
|
#define T1_SIG_SW 0x0004U /**< Context orientation : South-West direction */
|
||||||
#define T1_SIG_S 0x0040 /**< Context orientation : South direction */
|
#define T1_SIG_NW 0x0008U /**< Context orientation : North-West direction */
|
||||||
#define T1_SIG_W 0x0080 /**< Context orientation : West direction */
|
#define T1_SIG_N 0x0010U /**< Context orientation : North direction */
|
||||||
|
#define T1_SIG_E 0x0020U /**< Context orientation : East direction */
|
||||||
|
#define T1_SIG_S 0x0040U /**< Context orientation : South direction */
|
||||||
|
#define T1_SIG_W 0x0080U /**< Context orientation : West direction */
|
||||||
#define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW)
|
#define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW)
|
||||||
#define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
|
#define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
|
||||||
|
|
||||||
#define T1_SGN_N 0x0100
|
#define T1_SGN_N 0x0100U
|
||||||
#define T1_SGN_E 0x0200
|
#define T1_SGN_E 0x0200U
|
||||||
#define T1_SGN_S 0x0400
|
#define T1_SGN_S 0x0400U
|
||||||
#define T1_SGN_W 0x0800
|
#define T1_SGN_W 0x0800U
|
||||||
#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
|
#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
|
||||||
|
|
||||||
#define T1_SIG 0x1000
|
#define T1_SIG 0x1000U /**< No longer used by decoder */
|
||||||
#define T1_REFINE 0x2000
|
#define T1_REFINE 0x2000U /**< No longer used by decoder */
|
||||||
#define T1_VISIT 0x4000
|
#define T1_VISIT 0x4000U /**< No longer used by decoder */
|
||||||
|
/* END of flags that apply to opj_flag_t */
|
||||||
|
|
||||||
#define T1_NUMCTXS_ZC 9
|
#define T1_NUMCTXS_ZC 9
|
||||||
#define T1_NUMCTXS_SC 5
|
#define T1_NUMCTXS_SC 5
|
||||||
@ -89,9 +93,31 @@ in T1.C are used by some function in TCD.C.
|
|||||||
#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */
|
#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */
|
||||||
#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/
|
#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/
|
||||||
|
|
||||||
|
/* Those flags are used by opj_colflag_t */
|
||||||
|
#define T1_COLFLAG_RBS 4U /* RBS = Row Bit Shift */
|
||||||
|
#define T1_COLFLAG_SIG_OTHER_ROW_0 (1U << 0U) /**< This sample has at least one significant neighbour */
|
||||||
|
#define T1_COLFLAG_SIG_ROW_0 (1U << 1U) /**< This sample is significant */
|
||||||
|
#define T1_COLFLAG_VISIT_ROW_0 (1U << 2U) /**< This sample has been visited */
|
||||||
|
#define T1_COLFLAG_REFINE_ROW_0 (1U << 3U) /**< This sample has been refined */
|
||||||
|
#define T1_COLFLAG_SIG_OTHER_ROW_1 (T1_COLFLAG_SIG_OTHER_ROW_0 << (1U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_SIG_ROW_1 (T1_COLFLAG_SIG_ROW_0 << (1U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_VISIT_ROW_1 (T1_COLFLAG_VISIT_ROW_0 << (1U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_REFINE_ROW_1 (T1_COLFLAG_REFINE_ROW_0 << (1U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_SIG_OTHER_ROW_2 (T1_COLFLAG_SIG_OTHER_ROW_0 << (2U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_SIG_ROW_2 (T1_COLFLAG_SIG_ROW_0 << (2U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_VISIT_ROW_2 (T1_COLFLAG_VISIT_ROW_0 << (2U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_REFINE_ROW_2 (T1_COLFLAG_REFINE_ROW_0 << (2U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_SIG_OTHER_ROW_3 (T1_COLFLAG_SIG_OTHER_ROW_0 << (3U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_SIG_ROW_3 (T1_COLFLAG_SIG_ROW_0 << (3U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_VISIT_ROW_3 (T1_COLFLAG_VISIT_ROW_0 << (3U * T1_COLFLAG_RBS))
|
||||||
|
#define T1_COLFLAG_REFINE_ROW_3 (T1_COLFLAG_REFINE_ROW_0 << (3U * T1_COLFLAG_RBS))
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef OPJ_INT16 opj_flag_t;
|
typedef OPJ_UINT16 opj_flag_t;
|
||||||
|
|
||||||
|
/** Flags for 4 consecutive rows of a column */
|
||||||
|
typedef OPJ_UINT16 opj_colflag_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Tier-1 coding (coding of code-block coefficients)
|
Tier-1 coding (coding of code-block coefficients)
|
||||||
@ -105,11 +131,17 @@ typedef struct opj_t1 {
|
|||||||
|
|
||||||
OPJ_INT32 *data;
|
OPJ_INT32 *data;
|
||||||
opj_flag_t *flags;
|
opj_flag_t *flags;
|
||||||
|
/** Addition flag array such that colflags[1+0] is for state of col=0,row=0..3,
|
||||||
|
colflags[1+1] for col=1, row=0..3, colflags[1+flags_stride] for col=0,row=4..7, ...
|
||||||
|
This array avoids too much cache trashing when processing by 4 vertical samples
|
||||||
|
as done in the various decoding steps. */
|
||||||
|
opj_colflag_t* colflags;
|
||||||
OPJ_UINT32 w;
|
OPJ_UINT32 w;
|
||||||
OPJ_UINT32 h;
|
OPJ_UINT32 h;
|
||||||
OPJ_UINT32 datasize;
|
OPJ_UINT32 datasize;
|
||||||
OPJ_UINT32 flagssize;
|
OPJ_UINT32 flagssize;
|
||||||
OPJ_UINT32 flags_stride;
|
OPJ_UINT32 flags_stride;
|
||||||
|
OPJ_UINT32 colflags_size;
|
||||||
OPJ_UINT32 data_stride;
|
OPJ_UINT32 data_stride;
|
||||||
OPJ_BOOL encoder;
|
OPJ_BOOL encoder;
|
||||||
} opj_t1_t;
|
} opj_t1_t;
|
||||||
@ -140,7 +172,8 @@ Decode the code-blocks of a tile
|
|||||||
@param tilec The tile to decode
|
@param tilec The tile to decode
|
||||||
@param tccp Tile coding parameters
|
@param tccp Tile coding parameters
|
||||||
*/
|
*/
|
||||||
OPJ_BOOL opj_t1_decode_cblks( opj_t1_t* t1,
|
void opj_t1_decode_cblks( opj_thread_pool_t* tp,
|
||||||
|
volatile OPJ_BOOL* pret,
|
||||||
opj_tcd_tilecomp_t* tilec,
|
opj_tcd_tilecomp_t* tilec,
|
||||||
opj_tccp_t* tccp);
|
opj_tccp_t* tccp);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
|
||||||
static int t1_init_ctxno_zc(int f, int orient) {
|
static int t1_init_ctxno_zc(unsigned int f, unsigned int orient) {
|
||||||
int h, v, d, n, t, hv;
|
int h, v, d, n, t, hv;
|
||||||
h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
|
h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
|
||||||
v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
|
v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
|
||||||
@ -113,7 +113,7 @@ static int t1_init_ctxno_zc(int f, int orient) {
|
|||||||
return (T1_CTXNO_ZC + n);
|
return (T1_CTXNO_ZC + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int t1_init_ctxno_sc(int f) {
|
static int t1_init_ctxno_sc(unsigned int f) {
|
||||||
int hc, vc, n;
|
int hc, vc, n;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ static int t1_init_ctxno_sc(int f) {
|
|||||||
return (T1_CTXNO_SC + n);
|
return (T1_CTXNO_SC + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int t1_init_spb(int f) {
|
static int t1_init_spb(unsigned int f) {
|
||||||
int hc, vc, n;
|
int hc, vc, n;
|
||||||
|
|
||||||
hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
||||||
@ -192,7 +192,7 @@ static void dump_array16(int array[],int size){
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, j;
|
unsigned int i, j;
|
||||||
double u, v, t;
|
double u, v, t;
|
||||||
|
|
||||||
int lut_ctxno_zc[1024];
|
int lut_ctxno_zc[1024];
|
||||||
@ -205,47 +205,47 @@ int main(int argc, char **argv)
|
|||||||
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
|
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
|
||||||
|
|
||||||
/* lut_ctxno_zc */
|
/* lut_ctxno_zc */
|
||||||
for (j = 0; j < 4; ++j) {
|
for (j = 0U; j < 4U; ++j) {
|
||||||
for (i = 0; i < 256; ++i) {
|
for (i = 0U; i < 256U; ++i) {
|
||||||
int orient = j;
|
unsigned int orient = j;
|
||||||
if (orient == 2) {
|
if (orient == 2U) {
|
||||||
orient = 1;
|
orient = 1U;
|
||||||
} else if (orient == 1) {
|
} else if (orient == 1U) {
|
||||||
orient = 2;
|
orient = 2U;
|
||||||
}
|
}
|
||||||
lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
|
lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("static OPJ_BYTE lut_ctxno_zc[1024] = {\n ");
|
printf("static const OPJ_BYTE lut_ctxno_zc[1024] = {\n ");
|
||||||
for (i = 0; i < 1023; ++i) {
|
for (i = 0U; i < 1023U; ++i) {
|
||||||
printf("%i, ", lut_ctxno_zc[i]);
|
printf("%i, ", lut_ctxno_zc[i]);
|
||||||
if(!((i+1)&0x1f))
|
if(!((i+1U)&0x1fU))
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
}
|
}
|
||||||
printf("%i\n};\n\n", lut_ctxno_zc[1023]);
|
printf("%i\n};\n\n", lut_ctxno_zc[1023]);
|
||||||
|
|
||||||
/* lut_ctxno_sc */
|
/* lut_ctxno_sc */
|
||||||
printf("static OPJ_BYTE lut_ctxno_sc[256] = {\n ");
|
printf("static const OPJ_BYTE lut_ctxno_sc[256] = {\n ");
|
||||||
for (i = 0; i < 255; ++i) {
|
for (i = 0U; i < 255U; ++i) {
|
||||||
printf("0x%x, ", t1_init_ctxno_sc(i << 4));
|
printf("0x%x, ", t1_init_ctxno_sc(i << 4));
|
||||||
if(!((i+1)&0xf))
|
if(!((i+1U)&0xfU))
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
}
|
}
|
||||||
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4));
|
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255U << 4));
|
||||||
|
|
||||||
/* lut_spb */
|
/* lut_spb */
|
||||||
printf("static OPJ_BYTE lut_spb[256] = {\n ");
|
printf("static const OPJ_BYTE lut_spb[256] = {\n ");
|
||||||
for (i = 0; i < 255; ++i) {
|
for (i = 0U; i < 255U; ++i) {
|
||||||
printf("%i, ", t1_init_spb(i << 4));
|
printf("%i, ", t1_init_spb(i << 4));
|
||||||
if(!((i+1)&0x1f))
|
if(!((i+1U)&0x1fU))
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
}
|
}
|
||||||
printf("%i\n};\n\n", t1_init_spb(255 << 4));
|
printf("%i\n};\n\n", t1_init_spb(255U << 4));
|
||||||
|
|
||||||
/* FIXME FIXME FIXME */
|
/* FIXME FIXME FIXME */
|
||||||
/* fprintf(stdout,"nmsedec luts:\n"); */
|
/* fprintf(stdout,"nmsedec luts:\n"); */
|
||||||
for (i = 0; i < (1 << T1_NMSEDEC_BITS); ++i) {
|
for (i = 0U; i < (1U << T1_NMSEDEC_BITS); ++i) {
|
||||||
t = i / pow(2, T1_NMSEDEC_FRACBITS);
|
t = i / pow(2, T1_NMSEDEC_FRACBITS);
|
||||||
u = t;
|
u = t;
|
||||||
v = t - 1.5;
|
v = t - 1.5;
|
||||||
@ -269,17 +269,17 @@ int main(int argc, char **argv)
|
|||||||
(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
|
(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_sig, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
printf("static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_sig0, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
printf("static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_ref, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
printf("static OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_ref0, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* This file was automatically generated by t1_generate_luts.c */
|
/* This file was automatically generated by t1_generate_luts.c */
|
||||||
|
|
||||||
static OPJ_BYTE lut_ctxno_zc[1024] = {
|
static const OPJ_BYTE lut_ctxno_zc[1024] = {
|
||||||
0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
@ -35,7 +35,7 @@ static OPJ_BYTE lut_ctxno_zc[1024] = {
|
|||||||
2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8
|
2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8, 2, 5, 5, 7, 5, 7, 7, 8, 5, 7, 7, 8, 7, 8, 8, 8
|
||||||
};
|
};
|
||||||
|
|
||||||
static OPJ_BYTE lut_ctxno_sc[256] = {
|
static const OPJ_BYTE lut_ctxno_sc[256] = {
|
||||||
0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd,
|
0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd,
|
||||||
0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc,
|
0x9, 0xa, 0xc, 0xb, 0xa, 0x9, 0xd, 0xc, 0xc, 0xb, 0xc, 0xb, 0xd, 0xc, 0xd, 0xc,
|
||||||
0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa,
|
0x9, 0xa, 0xc, 0xb, 0xa, 0xa, 0xb, 0xb, 0xc, 0xd, 0x9, 0xa, 0xd, 0xd, 0xa, 0xa,
|
||||||
@ -54,7 +54,7 @@ static OPJ_BYTE lut_ctxno_sc[256] = {
|
|||||||
0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd
|
0x9, 0xa, 0xc, 0xd, 0xa, 0xa, 0xd, 0xd, 0xc, 0xd, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd
|
||||||
};
|
};
|
||||||
|
|
||||||
static OPJ_BYTE lut_spb[256] = {
|
static const OPJ_BYTE lut_spb[256] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@ -65,7 +65,7 @@ static OPJ_BYTE lut_spb[256] = {
|
|||||||
0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
|
static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
@ -84,7 +84,7 @@ static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
|
|||||||
0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680
|
0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680
|
||||||
};
|
};
|
||||||
|
|
||||||
static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
|
static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
|
||||||
0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
|
0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
|
||||||
0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
|
0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
|
||||||
@ -103,7 +103,7 @@ static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
|
|||||||
0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00
|
0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00
|
||||||
};
|
};
|
||||||
|
|
||||||
static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
|
static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {
|
||||||
0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480,
|
0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480,
|
||||||
0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080,
|
0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080,
|
||||||
0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80,
|
0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80,
|
||||||
@ -122,7 +122,7 @@ static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
|
|||||||
0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780
|
0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780
|
||||||
};
|
};
|
||||||
|
|
||||||
static OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {
|
static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {
|
||||||
0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980,
|
0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980,
|
||||||
0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300,
|
0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300,
|
||||||
0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00,
|
0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00,
|
||||||
|
@ -580,7 +580,8 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
|||||||
|
|
||||||
OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
||||||
opj_image_t * p_image,
|
opj_image_t * p_image,
|
||||||
opj_cp_t * p_cp )
|
opj_cp_t * p_cp,
|
||||||
|
opj_thread_pool_t* p_tp )
|
||||||
{
|
{
|
||||||
p_tcd->image = p_image;
|
p_tcd->image = p_image;
|
||||||
p_tcd->cp = p_cp;
|
p_tcd->cp = p_cp;
|
||||||
@ -597,6 +598,7 @@ OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
|||||||
|
|
||||||
p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
|
p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
|
||||||
p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
|
p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
|
||||||
|
p_tcd->thread_pool = p_tp;
|
||||||
|
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
@ -1588,30 +1590,22 @@ static OPJ_BOOL opj_tcd_t2_decode (opj_tcd_t *p_tcd,
|
|||||||
static OPJ_BOOL opj_tcd_t1_decode ( opj_tcd_t *p_tcd )
|
static OPJ_BOOL opj_tcd_t1_decode ( opj_tcd_t *p_tcd )
|
||||||
{
|
{
|
||||||
OPJ_UINT32 compno;
|
OPJ_UINT32 compno;
|
||||||
opj_t1_t * l_t1;
|
|
||||||
opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
|
opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
|
||||||
opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps;
|
opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps;
|
||||||
opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
|
opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
|
||||||
|
volatile OPJ_BOOL ret = OPJ_TRUE;
|
||||||
|
|
||||||
l_t1 = opj_t1_create(OPJ_FALSE);
|
|
||||||
if (l_t1 == 00) {
|
|
||||||
return OPJ_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (compno = 0; compno < l_tile->numcomps; ++compno) {
|
for (compno = 0; compno < l_tile->numcomps; ++compno) {
|
||||||
/* The +3 is headroom required by the vectorized DWT */
|
opj_t1_decode_cblks(p_tcd->thread_pool, &ret, l_tile_comp, l_tccp);
|
||||||
if (OPJ_FALSE == opj_t1_decode_cblks(l_t1, l_tile_comp, l_tccp)) {
|
if( !ret )
|
||||||
opj_t1_destroy(l_t1);
|
break;
|
||||||
return OPJ_FALSE;
|
|
||||||
}
|
|
||||||
++l_tile_comp;
|
++l_tile_comp;
|
||||||
++l_tccp;
|
++l_tccp;
|
||||||
}
|
}
|
||||||
|
|
||||||
opj_t1_destroy(l_t1);
|
opj_thread_pool_wait_completion(p_tcd->thread_pool, 0);
|
||||||
|
|
||||||
return OPJ_TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1638,7 +1632,7 @@ static OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (l_tccp->qmfbid == 1) {
|
if (l_tccp->qmfbid == 1) {
|
||||||
if (! opj_dwt_decode(l_tile_comp, l_img_comp->resno_decoded+1)) {
|
if (! opj_dwt_decode(p_tcd->thread_pool, l_tile_comp, l_img_comp->resno_decoded+1)) {
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ typedef struct opj_tcd_pass {
|
|||||||
OPJ_UINT32 rate;
|
OPJ_UINT32 rate;
|
||||||
OPJ_FLOAT64 distortiondec;
|
OPJ_FLOAT64 distortiondec;
|
||||||
OPJ_UINT32 len;
|
OPJ_UINT32 len;
|
||||||
OPJ_UINT32 term : 1;
|
OPJ_BITFIELD term : 1;
|
||||||
} opj_tcd_pass_t;
|
} opj_tcd_pass_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +219,9 @@ typedef struct opj_tcd
|
|||||||
/** current encoded/decoded tile */
|
/** current encoded/decoded tile */
|
||||||
OPJ_UINT32 tcd_tileno;
|
OPJ_UINT32 tcd_tileno;
|
||||||
/** tell if the tcd is a decoder. */
|
/** tell if the tcd is a decoder. */
|
||||||
OPJ_UINT32 m_is_decoder : 1;
|
OPJ_BITFIELD m_is_decoder : 1;
|
||||||
|
/** Thread pool */
|
||||||
|
opj_thread_pool_t* thread_pool;
|
||||||
} opj_tcd_t;
|
} opj_tcd_t;
|
||||||
|
|
||||||
/** @name Exported functions */
|
/** @name Exported functions */
|
||||||
@ -249,12 +251,14 @@ void opj_tcd_destroy(opj_tcd_t *tcd);
|
|||||||
* @param p_tcd TCD handle.
|
* @param p_tcd TCD handle.
|
||||||
* @param p_image raw image.
|
* @param p_image raw image.
|
||||||
* @param p_cp coding parameters.
|
* @param p_cp coding parameters.
|
||||||
|
* @param p_tp thread pool
|
||||||
*
|
*
|
||||||
* @return true if the encoding values could be set (false otherwise).
|
* @return true if the encoding values could be set (false otherwise).
|
||||||
*/
|
*/
|
||||||
OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
||||||
opj_image_t * p_image,
|
opj_image_t * p_image,
|
||||||
opj_cp_t * p_cp );
|
opj_cp_t * p_cp,
|
||||||
|
opj_thread_pool_t* p_tp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocates memory for decoding a specific tile.
|
* Allocates memory for decoding a specific tile.
|
||||||
|
968
src/lib/openjp2/thread.c
Normal file
968
src/lib/openjp2/thread.c
Normal file
@ -0,0 +1,968 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, Even Rouault
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "opj_includes.h"
|
||||||
|
|
||||||
|
#include "thread.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef MUTEX_win32
|
||||||
|
|
||||||
|
/* Some versions of x86_64-w64-mingw32-gc -m32 resolve InterlockedCompareExchange() */
|
||||||
|
/* as __sync_val_compare_and_swap_4 but fails to link it. As this protects against */
|
||||||
|
/* a rather unlikely race, skip it */
|
||||||
|
#if !(defined(__MINGW32__) && defined(__i386__))
|
||||||
|
#define HAVE_INTERLOCKED_COMPARE_EXCHANGE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void)
|
||||||
|
{
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int OPJ_CALLCONV opj_get_num_cpus(void)
|
||||||
|
{
|
||||||
|
SYSTEM_INFO info;
|
||||||
|
DWORD dwNum;
|
||||||
|
GetSystemInfo(&info);
|
||||||
|
dwNum = info.dwNumberOfProcessors;
|
||||||
|
if( dwNum < 1 )
|
||||||
|
return 1;
|
||||||
|
return (int)dwNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct opj_mutex_t
|
||||||
|
{
|
||||||
|
CRITICAL_SECTION cs;
|
||||||
|
};
|
||||||
|
|
||||||
|
opj_mutex_t* opj_mutex_create(void)
|
||||||
|
{
|
||||||
|
opj_mutex_t* mutex = (opj_mutex_t*) opj_malloc(sizeof(opj_mutex_t));
|
||||||
|
if( !mutex )
|
||||||
|
return NULL;
|
||||||
|
InitializeCriticalSectionAndSpinCount(&(mutex->cs), 4000);
|
||||||
|
return mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_lock(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
EnterCriticalSection( &(mutex->cs) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_unlock(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection( &(mutex->cs) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_destroy(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
if( !mutex ) return;
|
||||||
|
DeleteCriticalSection( &(mutex->cs) );
|
||||||
|
opj_free( mutex );
|
||||||
|
}
|
||||||
|
|
||||||
|
struct opj_cond_waiter_list_t
|
||||||
|
{
|
||||||
|
HANDLE hEvent;
|
||||||
|
struct opj_cond_waiter_list_t* next;
|
||||||
|
};
|
||||||
|
typedef struct opj_cond_waiter_list_t opj_cond_waiter_list_t;
|
||||||
|
|
||||||
|
struct opj_cond_t
|
||||||
|
{
|
||||||
|
opj_mutex_t *internal_mutex;
|
||||||
|
opj_cond_waiter_list_t *waiter_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
static DWORD TLSKey = 0;
|
||||||
|
static volatile LONG inTLSLockedSection = 0;
|
||||||
|
static volatile int TLSKeyInit = OPJ_FALSE;
|
||||||
|
|
||||||
|
opj_cond_t* opj_cond_create(void)
|
||||||
|
{
|
||||||
|
opj_cond_t* cond = (opj_cond_t*) opj_malloc(sizeof(opj_cond_t));
|
||||||
|
if( !cond )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Make sure that the TLS key is allocated in a thread-safe way */
|
||||||
|
/* We cannot use a global mutex/critical section since its creation itself would not be */
|
||||||
|
/* thread-safe, so use InterlockedCompareExchange trick */
|
||||||
|
while( OPJ_TRUE )
|
||||||
|
{
|
||||||
|
|
||||||
|
#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
|
||||||
|
if( InterlockedCompareExchange(&inTLSLockedSection, 1, 0) == 0 )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if( !TLSKeyInit )
|
||||||
|
{
|
||||||
|
TLSKey = TlsAlloc();
|
||||||
|
TLSKeyInit = OPJ_TRUE;
|
||||||
|
}
|
||||||
|
#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
|
||||||
|
InterlockedCompareExchange(&inTLSLockedSection, 0, 1);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( TLSKey == TLS_OUT_OF_INDEXES )
|
||||||
|
{
|
||||||
|
opj_free(cond);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
cond->internal_mutex = opj_mutex_create();
|
||||||
|
if (cond->internal_mutex == NULL)
|
||||||
|
{
|
||||||
|
opj_free(cond);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
cond->waiter_list = NULL;
|
||||||
|
return cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
opj_cond_waiter_list_t* item;
|
||||||
|
HANDLE hEvent = (HANDLE) TlsGetValue( TLSKey );
|
||||||
|
if (hEvent == NULL)
|
||||||
|
{
|
||||||
|
hEvent = CreateEvent(NULL, /* security attributes */
|
||||||
|
0, /* manual reset = no */
|
||||||
|
0, /* initial state = unsignaled */
|
||||||
|
NULL /* no name */);
|
||||||
|
assert(hEvent);
|
||||||
|
|
||||||
|
TlsSetValue( TLSKey, hEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Insert the waiter into the waiter list of the condition */
|
||||||
|
opj_mutex_lock(cond->internal_mutex);
|
||||||
|
|
||||||
|
item = (opj_cond_waiter_list_t*)opj_malloc(sizeof(opj_cond_waiter_list_t));
|
||||||
|
assert(item != NULL);
|
||||||
|
|
||||||
|
item->hEvent = hEvent;
|
||||||
|
item->next = cond->waiter_list;
|
||||||
|
|
||||||
|
cond->waiter_list = item;
|
||||||
|
|
||||||
|
opj_mutex_unlock(cond->internal_mutex);
|
||||||
|
|
||||||
|
/* Release the client mutex before waiting for the event being signaled */
|
||||||
|
opj_mutex_unlock(mutex);
|
||||||
|
|
||||||
|
/* Ideally we would check that we do not get WAIT_FAILED but it is hard */
|
||||||
|
/* to report a failure. */
|
||||||
|
WaitForSingleObject(hEvent, INFINITE);
|
||||||
|
|
||||||
|
/* Reacquire the client mutex */
|
||||||
|
opj_mutex_lock(mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_signal(opj_cond_t* cond)
|
||||||
|
{
|
||||||
|
opj_cond_waiter_list_t* psIter;
|
||||||
|
|
||||||
|
/* Signal the first registered event, and remove it from the list */
|
||||||
|
opj_mutex_lock(cond->internal_mutex);
|
||||||
|
|
||||||
|
psIter = cond->waiter_list;
|
||||||
|
if (psIter != NULL)
|
||||||
|
{
|
||||||
|
SetEvent(psIter->hEvent);
|
||||||
|
cond->waiter_list = psIter->next;
|
||||||
|
opj_free(psIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_mutex_unlock(cond->internal_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_destroy(opj_cond_t* cond)
|
||||||
|
{
|
||||||
|
if( !cond ) return;
|
||||||
|
opj_mutex_destroy(cond->internal_mutex);
|
||||||
|
assert(cond->waiter_list == NULL);
|
||||||
|
opj_free(cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct opj_thread_t
|
||||||
|
{
|
||||||
|
opj_thread_fn thread_fn;
|
||||||
|
void* user_data;
|
||||||
|
HANDLE hThread;
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int __stdcall opj_thread_callback_adapter( void *info )
|
||||||
|
{
|
||||||
|
opj_thread_t* thread = (opj_thread_t*) info;
|
||||||
|
HANDLE hEvent = NULL;
|
||||||
|
|
||||||
|
thread->thread_fn( thread->user_data );
|
||||||
|
|
||||||
|
/* Free the handle possible allocated by a cond */
|
||||||
|
while( OPJ_TRUE )
|
||||||
|
{
|
||||||
|
/* Make sure TLSKey is not being created just at that moment... */
|
||||||
|
#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
|
||||||
|
if( InterlockedCompareExchange(&inTLSLockedSection, 1, 0) == 0 )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if( TLSKeyInit )
|
||||||
|
{
|
||||||
|
hEvent = (HANDLE) TlsGetValue( TLSKey );
|
||||||
|
}
|
||||||
|
#if HAVE_INTERLOCKED_COMPARE_EXCHANGE
|
||||||
|
InterlockedCompareExchange(&inTLSLockedSection, 0, 1);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( hEvent )
|
||||||
|
CloseHandle(hEvent);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_thread_t* opj_thread_create( opj_thread_fn thread_fn, void* user_data )
|
||||||
|
{
|
||||||
|
opj_thread_t* thread;
|
||||||
|
|
||||||
|
assert( thread_fn );
|
||||||
|
|
||||||
|
thread = (opj_thread_t*) opj_malloc( sizeof(opj_thread_t) );
|
||||||
|
if( !thread )
|
||||||
|
return NULL;
|
||||||
|
thread->thread_fn = thread_fn;
|
||||||
|
thread->user_data = user_data;
|
||||||
|
|
||||||
|
thread->hThread = (HANDLE)_beginthreadex(NULL, 0,
|
||||||
|
opj_thread_callback_adapter, thread, 0, NULL);
|
||||||
|
|
||||||
|
if( thread->hThread == NULL )
|
||||||
|
{
|
||||||
|
opj_free( thread );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_thread_join( opj_thread_t* thread )
|
||||||
|
{
|
||||||
|
WaitForSingleObject(thread->hThread, INFINITE);
|
||||||
|
CloseHandle( thread->hThread );
|
||||||
|
|
||||||
|
opj_free(thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif MUTEX_pthread
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void)
|
||||||
|
{
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int OPJ_CALLCONV opj_get_num_cpus(void)
|
||||||
|
{
|
||||||
|
#ifdef _SC_NPROCESSORS_ONLN
|
||||||
|
return (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
struct opj_mutex_t
|
||||||
|
{
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
opj_mutex_t* opj_mutex_create(void)
|
||||||
|
{
|
||||||
|
opj_mutex_t* mutex = (opj_mutex_t*) opj_calloc(1U, sizeof(opj_mutex_t));
|
||||||
|
if( mutex != NULL ) {
|
||||||
|
if ( pthread_mutex_init(&mutex->mutex, NULL) != 0) {
|
||||||
|
opj_free(mutex);
|
||||||
|
mutex = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_lock(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&(mutex->mutex));
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_unlock(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&(mutex->mutex));
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_destroy(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
if( !mutex ) return;
|
||||||
|
pthread_mutex_destroy(&(mutex->mutex));
|
||||||
|
opj_free(mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct opj_cond_t
|
||||||
|
{
|
||||||
|
pthread_cond_t cond;
|
||||||
|
};
|
||||||
|
|
||||||
|
opj_cond_t* opj_cond_create(void)
|
||||||
|
{
|
||||||
|
opj_cond_t* cond = (opj_cond_t*) opj_malloc(sizeof(opj_cond_t));
|
||||||
|
if( !cond )
|
||||||
|
return NULL;
|
||||||
|
if( pthread_cond_init(&(cond->cond), NULL) != 0 )
|
||||||
|
{
|
||||||
|
opj_free(cond);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
pthread_cond_wait(&(cond->cond), &(mutex->mutex));
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_signal(opj_cond_t* cond)
|
||||||
|
{
|
||||||
|
int ret = pthread_cond_signal(&(cond->cond));
|
||||||
|
(void)ret;
|
||||||
|
assert(ret == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_destroy(opj_cond_t* cond)
|
||||||
|
{
|
||||||
|
if( !cond ) return;
|
||||||
|
pthread_cond_destroy(&(cond->cond));
|
||||||
|
opj_free(cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct opj_thread_t
|
||||||
|
{
|
||||||
|
opj_thread_fn thread_fn;
|
||||||
|
void* user_data;
|
||||||
|
pthread_t thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void* opj_thread_callback_adapter( void* info )
|
||||||
|
{
|
||||||
|
opj_thread_t* thread = (opj_thread_t*) info;
|
||||||
|
thread->thread_fn( thread->user_data );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_thread_t* opj_thread_create( opj_thread_fn thread_fn, void* user_data )
|
||||||
|
{
|
||||||
|
pthread_attr_t attr;
|
||||||
|
opj_thread_t* thread;
|
||||||
|
|
||||||
|
assert( thread_fn );
|
||||||
|
|
||||||
|
thread = (opj_thread_t*) opj_malloc( sizeof(opj_thread_t) );
|
||||||
|
if( !thread )
|
||||||
|
return NULL;
|
||||||
|
thread->thread_fn = thread_fn;
|
||||||
|
thread->user_data = user_data;
|
||||||
|
|
||||||
|
pthread_attr_init( &attr );
|
||||||
|
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE );
|
||||||
|
if( pthread_create( &(thread->thread), &attr,
|
||||||
|
opj_thread_callback_adapter, (void *) thread ) != 0 )
|
||||||
|
{
|
||||||
|
opj_free( thread );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_thread_join( opj_thread_t* thread )
|
||||||
|
{
|
||||||
|
void* status;
|
||||||
|
pthread_join( thread->thread, &status);
|
||||||
|
|
||||||
|
opj_free(thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* Stub implementation */
|
||||||
|
|
||||||
|
OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void)
|
||||||
|
{
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int OPJ_CALLCONV opj_get_num_cpus(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_mutex_t* opj_mutex_create(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_lock(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
(void) mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_unlock(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
(void) mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_mutex_destroy(opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
(void) mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_cond_t* opj_cond_create(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
(void) cond;
|
||||||
|
(void) mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_signal(opj_cond_t* cond)
|
||||||
|
{
|
||||||
|
(void) cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_cond_destroy(opj_cond_t* cond)
|
||||||
|
{
|
||||||
|
(void) cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_thread_t* opj_thread_create( opj_thread_fn thread_fn, void* user_data )
|
||||||
|
{
|
||||||
|
(void) thread_fn;
|
||||||
|
(void) user_data;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_thread_join( opj_thread_t* thread )
|
||||||
|
{
|
||||||
|
(void) thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int key;
|
||||||
|
void* value;
|
||||||
|
opj_tls_free_func opj_free_func;
|
||||||
|
} opj_tls_key_val_t;
|
||||||
|
|
||||||
|
struct opj_tls_t
|
||||||
|
{
|
||||||
|
opj_tls_key_val_t* key_val;
|
||||||
|
int key_val_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
static opj_tls_t* opj_tls_new(void)
|
||||||
|
{
|
||||||
|
return (opj_tls_t*) opj_calloc(1, sizeof(opj_tls_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void opj_tls_destroy(opj_tls_t* tls)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if( !tls ) return;
|
||||||
|
for(i=0;i<tls->key_val_count;i++)
|
||||||
|
{
|
||||||
|
if( tls->key_val[i].opj_free_func )
|
||||||
|
tls->key_val[i].opj_free_func(tls->key_val[i].value);
|
||||||
|
}
|
||||||
|
opj_free(tls->key_val);
|
||||||
|
opj_free(tls);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* opj_tls_get(opj_tls_t* tls, int key)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0;i<tls->key_val_count;i++)
|
||||||
|
{
|
||||||
|
if( tls->key_val[i].key == key )
|
||||||
|
return tls->key_val[i].value;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value, opj_tls_free_func opj_free_func)
|
||||||
|
{
|
||||||
|
opj_tls_key_val_t* new_key_val;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (tls->key_val_count == INT_MAX) {
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
for(i=0;i<tls->key_val_count;i++)
|
||||||
|
{
|
||||||
|
if( tls->key_val[i].key == key )
|
||||||
|
{
|
||||||
|
if( tls->key_val[i].opj_free_func ) {
|
||||||
|
tls->key_val[i].opj_free_func(tls->key_val[i].value);
|
||||||
|
}
|
||||||
|
tls->key_val[i].value = value;
|
||||||
|
tls->key_val[i].opj_free_func = opj_free_func;
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new_key_val = (opj_tls_key_val_t*) opj_realloc( tls->key_val,
|
||||||
|
((size_t)tls->key_val_count + 1U) * sizeof(opj_tls_key_val_t) );
|
||||||
|
if( !new_key_val )
|
||||||
|
return OPJ_FALSE;
|
||||||
|
tls->key_val = new_key_val;
|
||||||
|
new_key_val[tls->key_val_count].key = key;
|
||||||
|
new_key_val[tls->key_val_count].value = value;
|
||||||
|
new_key_val[tls->key_val_count].opj_free_func = opj_free_func;
|
||||||
|
tls->key_val_count ++;
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
opj_job_fn job_fn;
|
||||||
|
void *user_data;
|
||||||
|
} opj_worker_thread_job_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
opj_thread_pool_t *tp;
|
||||||
|
opj_thread_t *thread;
|
||||||
|
int marked_as_waiting;
|
||||||
|
|
||||||
|
opj_mutex_t *mutex;
|
||||||
|
opj_cond_t *cond;
|
||||||
|
} opj_worker_thread_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
OPJWTS_OK,
|
||||||
|
OPJWTS_STOP,
|
||||||
|
OPJWTS_ERROR
|
||||||
|
} opj_worker_thread_state;
|
||||||
|
|
||||||
|
struct opj_job_list_t
|
||||||
|
{
|
||||||
|
opj_worker_thread_job_t* job;
|
||||||
|
struct opj_job_list_t* next;
|
||||||
|
};
|
||||||
|
typedef struct opj_job_list_t opj_job_list_t;
|
||||||
|
|
||||||
|
struct opj_worker_thread_list_t
|
||||||
|
{
|
||||||
|
opj_worker_thread_t* worker_thread;
|
||||||
|
struct opj_worker_thread_list_t* next;
|
||||||
|
};
|
||||||
|
typedef struct opj_worker_thread_list_t opj_worker_thread_list_t;
|
||||||
|
|
||||||
|
struct opj_thread_pool_t
|
||||||
|
{
|
||||||
|
opj_worker_thread_t* worker_threads;
|
||||||
|
int worker_threads_count;
|
||||||
|
opj_cond_t* cond;
|
||||||
|
opj_mutex_t* mutex;
|
||||||
|
volatile opj_worker_thread_state state;
|
||||||
|
opj_job_list_t* job_queue;
|
||||||
|
volatile int pending_jobs_count;
|
||||||
|
opj_worker_thread_list_t* waiting_worker_thread_list;
|
||||||
|
int waiting_worker_thread_count;
|
||||||
|
opj_tls_t* tls;
|
||||||
|
int signaling_threshold;
|
||||||
|
};
|
||||||
|
|
||||||
|
static OPJ_BOOL opj_thread_pool_setup(opj_thread_pool_t* tp, int num_threads);
|
||||||
|
static opj_worker_thread_job_t* opj_thread_pool_get_next_job(opj_thread_pool_t* tp,
|
||||||
|
opj_worker_thread_t* worker_thread,
|
||||||
|
OPJ_BOOL signal_job_finished);
|
||||||
|
|
||||||
|
opj_thread_pool_t* opj_thread_pool_create(int num_threads)
|
||||||
|
{
|
||||||
|
opj_thread_pool_t* tp;
|
||||||
|
|
||||||
|
tp = (opj_thread_pool_t*) opj_calloc(1, sizeof(opj_thread_pool_t));
|
||||||
|
if( !tp )
|
||||||
|
return NULL;
|
||||||
|
tp->state = OPJWTS_OK;
|
||||||
|
|
||||||
|
if( num_threads <= 0 )
|
||||||
|
{
|
||||||
|
tp->tls = opj_tls_new();
|
||||||
|
if( !tp->tls )
|
||||||
|
{
|
||||||
|
opj_free(tp);
|
||||||
|
tp = NULL;
|
||||||
|
}
|
||||||
|
return tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
tp->mutex = opj_mutex_create();
|
||||||
|
if( !tp->mutex )
|
||||||
|
{
|
||||||
|
opj_free(tp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if( !opj_thread_pool_setup(tp, num_threads) )
|
||||||
|
{
|
||||||
|
opj_thread_pool_destroy(tp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void opj_worker_thread_function(void* user_data)
|
||||||
|
{
|
||||||
|
opj_worker_thread_t* worker_thread;
|
||||||
|
opj_thread_pool_t* tp;
|
||||||
|
opj_tls_t* tls;
|
||||||
|
OPJ_BOOL job_finished = OPJ_FALSE;
|
||||||
|
|
||||||
|
worker_thread = (opj_worker_thread_t* ) user_data;
|
||||||
|
tp = worker_thread->tp;
|
||||||
|
tls = opj_tls_new();
|
||||||
|
|
||||||
|
while( OPJ_TRUE )
|
||||||
|
{
|
||||||
|
opj_worker_thread_job_t* job = opj_thread_pool_get_next_job(tp, worker_thread, job_finished);
|
||||||
|
if( job == NULL )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if( job->job_fn )
|
||||||
|
{
|
||||||
|
job->job_fn(job->user_data, tls);
|
||||||
|
}
|
||||||
|
opj_free(job);
|
||||||
|
job_finished = OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_tls_destroy(tls);
|
||||||
|
}
|
||||||
|
|
||||||
|
static OPJ_BOOL opj_thread_pool_setup(opj_thread_pool_t* tp, int num_threads)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
OPJ_BOOL bRet = OPJ_TRUE;
|
||||||
|
|
||||||
|
assert( num_threads > 0 );
|
||||||
|
|
||||||
|
tp->cond = opj_cond_create();
|
||||||
|
if( tp->cond == NULL )
|
||||||
|
return OPJ_FALSE;
|
||||||
|
|
||||||
|
tp->worker_threads = (opj_worker_thread_t*) opj_calloc( (size_t)num_threads,
|
||||||
|
sizeof(opj_worker_thread_t) );
|
||||||
|
if( tp->worker_threads == NULL )
|
||||||
|
return OPJ_FALSE;
|
||||||
|
tp->worker_threads_count = num_threads;
|
||||||
|
|
||||||
|
for(i=0;i<num_threads;i++)
|
||||||
|
{
|
||||||
|
tp->worker_threads[i].tp = tp;
|
||||||
|
|
||||||
|
tp->worker_threads[i].mutex = opj_mutex_create();
|
||||||
|
if( tp->worker_threads[i].mutex == NULL )
|
||||||
|
{
|
||||||
|
tp->worker_threads_count = i;
|
||||||
|
bRet = OPJ_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tp->worker_threads[i].cond = opj_cond_create();
|
||||||
|
if( tp->worker_threads[i].cond == NULL )
|
||||||
|
{
|
||||||
|
opj_mutex_destroy(tp->worker_threads[i].mutex);
|
||||||
|
tp->worker_threads_count = i;
|
||||||
|
bRet = OPJ_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tp->worker_threads[i].marked_as_waiting = OPJ_FALSE;
|
||||||
|
|
||||||
|
tp->worker_threads[i].thread = opj_thread_create(opj_worker_thread_function,
|
||||||
|
&(tp->worker_threads[i]));
|
||||||
|
if( tp->worker_threads[i].thread == NULL )
|
||||||
|
{
|
||||||
|
tp->worker_threads_count = i;
|
||||||
|
bRet = OPJ_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait all threads to be started */
|
||||||
|
/* printf("waiting for all threads to be started\n"); */
|
||||||
|
opj_mutex_lock(tp->mutex);
|
||||||
|
while( tp->waiting_worker_thread_count < num_threads )
|
||||||
|
{
|
||||||
|
opj_cond_wait(tp->cond, tp->mutex);
|
||||||
|
}
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
/* printf("all threads started\n"); */
|
||||||
|
|
||||||
|
if( tp->state == OPJWTS_ERROR )
|
||||||
|
bRet = OPJ_FALSE;
|
||||||
|
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void opj_waiting()
|
||||||
|
{
|
||||||
|
printf("waiting!\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static opj_worker_thread_job_t* opj_thread_pool_get_next_job(opj_thread_pool_t* tp,
|
||||||
|
opj_worker_thread_t* worker_thread,
|
||||||
|
OPJ_BOOL signal_job_finished)
|
||||||
|
{
|
||||||
|
while( OPJ_TRUE )
|
||||||
|
{
|
||||||
|
opj_job_list_t* top_job_iter;
|
||||||
|
|
||||||
|
opj_mutex_lock(tp->mutex);
|
||||||
|
|
||||||
|
if( signal_job_finished )
|
||||||
|
{
|
||||||
|
signal_job_finished = OPJ_FALSE;
|
||||||
|
tp->pending_jobs_count --;
|
||||||
|
/*printf("tp=%p, remaining jobs: %d\n", tp, tp->pending_jobs_count);*/
|
||||||
|
if( tp->pending_jobs_count <= tp->signaling_threshold )
|
||||||
|
opj_cond_signal(tp->cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tp->state == OPJWTS_STOP )
|
||||||
|
{
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
top_job_iter = tp->job_queue;
|
||||||
|
if( top_job_iter )
|
||||||
|
{
|
||||||
|
opj_worker_thread_job_t* job;
|
||||||
|
tp->job_queue = top_job_iter->next;
|
||||||
|
|
||||||
|
job = top_job_iter->job;
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
opj_free(top_job_iter);
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* opj_waiting(); */
|
||||||
|
if( !worker_thread->marked_as_waiting )
|
||||||
|
{
|
||||||
|
opj_worker_thread_list_t* item;
|
||||||
|
|
||||||
|
worker_thread->marked_as_waiting = OPJ_TRUE;
|
||||||
|
tp->waiting_worker_thread_count ++;
|
||||||
|
assert(tp->waiting_worker_thread_count <= tp->worker_threads_count);
|
||||||
|
|
||||||
|
item= (opj_worker_thread_list_t*) opj_malloc(sizeof(opj_worker_thread_list_t));
|
||||||
|
if( item == NULL )
|
||||||
|
{
|
||||||
|
tp->state = OPJWTS_ERROR;
|
||||||
|
opj_cond_signal(tp->cond);
|
||||||
|
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
item->worker_thread = worker_thread;
|
||||||
|
item->next = tp->waiting_worker_thread_list;
|
||||||
|
tp->waiting_worker_thread_list = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* printf("signaling that worker thread is ready\n"); */
|
||||||
|
opj_cond_signal(tp->cond);
|
||||||
|
|
||||||
|
opj_mutex_lock(worker_thread->mutex);
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
|
||||||
|
/* printf("waiting for job\n"); */
|
||||||
|
opj_cond_wait( worker_thread->cond, worker_thread->mutex );
|
||||||
|
|
||||||
|
opj_mutex_unlock(worker_thread->mutex);
|
||||||
|
/* printf("got job\n"); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp,
|
||||||
|
opj_job_fn job_fn,
|
||||||
|
void* user_data)
|
||||||
|
{
|
||||||
|
opj_worker_thread_job_t* job;
|
||||||
|
opj_job_list_t* item;
|
||||||
|
|
||||||
|
if( tp->mutex == NULL )
|
||||||
|
{
|
||||||
|
job_fn( user_data, tp->tls );
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
job = (opj_worker_thread_job_t*)opj_malloc(sizeof(opj_worker_thread_job_t));
|
||||||
|
if( job == NULL )
|
||||||
|
return OPJ_FALSE;
|
||||||
|
job->job_fn = job_fn;
|
||||||
|
job->user_data = user_data;
|
||||||
|
|
||||||
|
item = (opj_job_list_t*) opj_malloc(sizeof(opj_job_list_t));
|
||||||
|
if( item == NULL )
|
||||||
|
{
|
||||||
|
opj_free(job);
|
||||||
|
return OPJ_FALSE;
|
||||||
|
}
|
||||||
|
item->job = job;
|
||||||
|
|
||||||
|
opj_mutex_lock(tp->mutex);
|
||||||
|
|
||||||
|
tp->signaling_threshold = 100 * tp->worker_threads_count;
|
||||||
|
while( tp->pending_jobs_count > tp->signaling_threshold )
|
||||||
|
{
|
||||||
|
/* printf("%d jobs enqueued. Waiting\n", tp->pending_jobs_count); */
|
||||||
|
opj_cond_wait(tp->cond, tp->mutex);
|
||||||
|
/* printf("...%d jobs enqueued.\n", tp->pending_jobs_count); */
|
||||||
|
}
|
||||||
|
|
||||||
|
item->next = tp->job_queue;
|
||||||
|
tp->job_queue = item;
|
||||||
|
tp->pending_jobs_count ++;
|
||||||
|
|
||||||
|
if( tp->waiting_worker_thread_list )
|
||||||
|
{
|
||||||
|
opj_worker_thread_t* worker_thread;
|
||||||
|
opj_worker_thread_list_t* next;
|
||||||
|
opj_worker_thread_list_t* to_opj_free;
|
||||||
|
|
||||||
|
worker_thread = tp->waiting_worker_thread_list->worker_thread;
|
||||||
|
|
||||||
|
assert( worker_thread->marked_as_waiting );
|
||||||
|
worker_thread->marked_as_waiting = OPJ_FALSE;
|
||||||
|
|
||||||
|
next = tp->waiting_worker_thread_list->next;
|
||||||
|
to_opj_free = tp->waiting_worker_thread_list;
|
||||||
|
tp->waiting_worker_thread_list = next;
|
||||||
|
tp->waiting_worker_thread_count --;
|
||||||
|
|
||||||
|
opj_mutex_lock(worker_thread->mutex);
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
opj_cond_signal(worker_thread->cond);
|
||||||
|
opj_mutex_unlock(worker_thread->mutex);
|
||||||
|
|
||||||
|
opj_free(to_opj_free);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_thread_pool_wait_completion(opj_thread_pool_t* tp, int max_remaining_jobs)
|
||||||
|
{
|
||||||
|
if( tp->mutex == NULL )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( max_remaining_jobs < 0 )
|
||||||
|
max_remaining_jobs = 0;
|
||||||
|
opj_mutex_lock(tp->mutex);
|
||||||
|
tp->signaling_threshold = max_remaining_jobs;
|
||||||
|
while( tp->pending_jobs_count > max_remaining_jobs )
|
||||||
|
{
|
||||||
|
/*printf("tp=%p, jobs before wait = %d, max_remaining_jobs = %d\n", tp, tp->pending_jobs_count, max_remaining_jobs);*/
|
||||||
|
opj_cond_wait(tp->cond, tp->mutex);
|
||||||
|
/*printf("tp=%p, jobs after wait = %d\n", tp, tp->pending_jobs_count);*/
|
||||||
|
}
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int opj_thread_pool_get_thread_count(opj_thread_pool_t* tp)
|
||||||
|
{
|
||||||
|
return tp->worker_threads_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void opj_thread_pool_destroy(opj_thread_pool_t* tp)
|
||||||
|
{
|
||||||
|
if( !tp ) return;
|
||||||
|
if( tp->cond )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
opj_thread_pool_wait_completion(tp, 0);
|
||||||
|
|
||||||
|
opj_mutex_lock(tp->mutex);
|
||||||
|
tp->state = OPJWTS_STOP;
|
||||||
|
opj_mutex_unlock(tp->mutex);
|
||||||
|
|
||||||
|
for(i=0;i<tp->worker_threads_count;i++)
|
||||||
|
{
|
||||||
|
opj_mutex_lock(tp->worker_threads[i].mutex);
|
||||||
|
opj_cond_signal(tp->worker_threads[i].cond);
|
||||||
|
opj_mutex_unlock(tp->worker_threads[i].mutex);
|
||||||
|
opj_thread_join(tp->worker_threads[i].thread);
|
||||||
|
opj_cond_destroy(tp->worker_threads[i].cond);
|
||||||
|
opj_mutex_destroy(tp->worker_threads[i].mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_free(tp->worker_threads);
|
||||||
|
|
||||||
|
while( tp->waiting_worker_thread_list != NULL )
|
||||||
|
{
|
||||||
|
opj_worker_thread_list_t* next = tp->waiting_worker_thread_list->next;
|
||||||
|
opj_free( tp->waiting_worker_thread_list );
|
||||||
|
tp->waiting_worker_thread_list = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_cond_destroy(tp->cond);
|
||||||
|
}
|
||||||
|
opj_mutex_destroy(tp->mutex);
|
||||||
|
opj_tls_destroy(tp->tls);
|
||||||
|
opj_free(tp);
|
||||||
|
}
|
253
src/lib/openjp2/thread.h
Normal file
253
src/lib/openjp2/thread.h
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, Even Rouault
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef THREAD_H
|
||||||
|
#define THREAD_H
|
||||||
|
|
||||||
|
#include "openjpeg.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file thread.h
|
||||||
|
@brief Thread API
|
||||||
|
|
||||||
|
The functions in thread.c have for goal to manage mutex, conditions, thread
|
||||||
|
creation and thread pools that accept jobs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup THREAD THREAD - Mutex, conditions, threads and thread pools */
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** @name Mutex */
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** Opaque type for a mutex */
|
||||||
|
typedef struct opj_mutex_t opj_mutex_t;
|
||||||
|
|
||||||
|
/** Creates a mutex.
|
||||||
|
* @return the mutex or NULL in case of error (can for example happen if the library
|
||||||
|
* is built without thread support)
|
||||||
|
*/
|
||||||
|
opj_mutex_t* opj_mutex_create(void);
|
||||||
|
|
||||||
|
/** Lock/acquire the mutex.
|
||||||
|
* @param mutex the mutex to acquire.
|
||||||
|
*/
|
||||||
|
void opj_mutex_lock(opj_mutex_t* mutex);
|
||||||
|
|
||||||
|
/** Unlock/release the mutex.
|
||||||
|
* @param mutex the mutex to release.
|
||||||
|
*/
|
||||||
|
void opj_mutex_unlock(opj_mutex_t* mutex);
|
||||||
|
|
||||||
|
/** Destroy a mutex
|
||||||
|
* @param mutex the mutex to destroy.
|
||||||
|
*/
|
||||||
|
void opj_mutex_destroy(opj_mutex_t* mutex);
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
/** @name Condition */
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** Opaque type for a condition */
|
||||||
|
typedef struct opj_cond_t opj_cond_t;
|
||||||
|
|
||||||
|
/** Creates a condition.
|
||||||
|
* @return the condition or NULL in case of error (can for example happen if the library
|
||||||
|
* is built without thread support)
|
||||||
|
*/
|
||||||
|
opj_cond_t* opj_cond_create(void);
|
||||||
|
|
||||||
|
/** Wait for the condition to be signaled.
|
||||||
|
* The semantics is the same as the POSIX pthread_cond_wait.
|
||||||
|
* The provided mutex *must* be acquired before calling this function, and
|
||||||
|
* released afterwards.
|
||||||
|
* The mutex will be released by this function while it must wait for the condition
|
||||||
|
* and reacquired afterwards.
|
||||||
|
* In some particular situations, the function might return even if the condition is not signaled
|
||||||
|
* with opj_cond_signal(), hence the need to check with an application level
|
||||||
|
* mechanism.
|
||||||
|
*
|
||||||
|
* Waiting thread :
|
||||||
|
* \code
|
||||||
|
* opj_mutex_lock(mutex);
|
||||||
|
* while( !some_application_level_condition )
|
||||||
|
* {
|
||||||
|
* opj_cond_wait(cond, mutex);
|
||||||
|
* }
|
||||||
|
* opj_mutex_unlock(mutex);
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* Signaling thread :
|
||||||
|
* \code
|
||||||
|
* opj_mutex_lock(mutex);
|
||||||
|
* some_application_level_condition = TRUE;
|
||||||
|
* opj_cond_signal(cond);
|
||||||
|
* opj_mutex_unlock(mutex);
|
||||||
|
* \endcode
|
||||||
|
*
|
||||||
|
* @param cond the condition to wait.
|
||||||
|
* @param mutex the mutex (in acquired state before calling this function)
|
||||||
|
*/
|
||||||
|
void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex);
|
||||||
|
|
||||||
|
/** Signal waiting threads on a condition.
|
||||||
|
* One of the thread waiting with opj_cond_wait() will be waken up.
|
||||||
|
* It is strongly advised that this call is done with the mutex that is used
|
||||||
|
* by opj_cond_wait(), in a acquired state.
|
||||||
|
* @param cond the condition to signal.
|
||||||
|
*/
|
||||||
|
void opj_cond_signal(opj_cond_t* cond);
|
||||||
|
|
||||||
|
/** Destroy a condition
|
||||||
|
* @param cond the condition to destroy.
|
||||||
|
*/
|
||||||
|
void opj_cond_destroy(opj_cond_t* cond);
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
/** @name Thread */
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** Opaque type for a thread handle */
|
||||||
|
typedef struct opj_thread_t opj_thread_t;
|
||||||
|
|
||||||
|
/** User function to execute in a thread
|
||||||
|
* @param user_data user data provided with opj_thread_create()
|
||||||
|
*/
|
||||||
|
typedef void (*opj_thread_fn)(void* user_data);
|
||||||
|
|
||||||
|
/** Creates a new thread.
|
||||||
|
* @param thread_fn Function to run in the new thread.
|
||||||
|
* @param user_data user data provided to the thread function. Might be NULL.
|
||||||
|
* @return a thread handle or NULL in case of failure (can for example happen if the library
|
||||||
|
* is built without thread support)
|
||||||
|
*/
|
||||||
|
opj_thread_t* opj_thread_create( opj_thread_fn thread_fn, void* user_data );
|
||||||
|
|
||||||
|
/** Wait for a thread to be finished and release associated resources to the
|
||||||
|
* thread handle.
|
||||||
|
* @param thread the thread to wait for being finished.
|
||||||
|
*/
|
||||||
|
void opj_thread_join( opj_thread_t* thread );
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
/** @name Thread local storage */
|
||||||
|
/*@{*/
|
||||||
|
/** Opaque type for a thread local storage */
|
||||||
|
typedef struct opj_tls_t opj_tls_t;
|
||||||
|
|
||||||
|
/** Get a thread local value corresponding to the provided key.
|
||||||
|
* @param tls thread local storage handle
|
||||||
|
* @param key key whose value to retrieve.
|
||||||
|
* @return value associated with the key, or NULL is missing.
|
||||||
|
*/
|
||||||
|
void* opj_tls_get(opj_tls_t* tls, int key);
|
||||||
|
|
||||||
|
/** Type of the function used to free a TLS value */
|
||||||
|
typedef void (*opj_tls_free_func)(void* value);
|
||||||
|
|
||||||
|
/** Set a thread local value corresponding to the provided key.
|
||||||
|
* @param tls thread local storage handle
|
||||||
|
* @param key key whose value to set.
|
||||||
|
* @param value value to set (may be NULL).
|
||||||
|
* @param free_func function to call currently installed value.
|
||||||
|
* @return OPJ_TRUE if successful.
|
||||||
|
*/
|
||||||
|
OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value, opj_tls_free_func free_func);
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
/** @name Thread pool */
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** Opaque type for a thread pool */
|
||||||
|
typedef struct opj_thread_pool_t opj_thread_pool_t;
|
||||||
|
|
||||||
|
/** Create a new thread pool.
|
||||||
|
* num_thread must nominally be >= 1 to create a real thread pool. If num_threads
|
||||||
|
* is negative or null, then a dummy thread pool will be created. All functions
|
||||||
|
* operating on the thread pool will work, but job submission will be run
|
||||||
|
* synchronously in the calling thread.
|
||||||
|
*
|
||||||
|
* @param num_threads the number of threads to allocate for this thread pool.
|
||||||
|
* @return a thread pool handle, or NULL in case of failure (can for example happen if the library
|
||||||
|
* is built without thread support)
|
||||||
|
*/
|
||||||
|
opj_thread_pool_t* opj_thread_pool_create(int num_threads);
|
||||||
|
|
||||||
|
/** User function to execute in a thread
|
||||||
|
* @param user_data user data provided with opj_thread_create()
|
||||||
|
* @param tls handle to thread local storage
|
||||||
|
*/
|
||||||
|
typedef void (*opj_job_fn)(void* user_data, opj_tls_t* tls);
|
||||||
|
|
||||||
|
|
||||||
|
/** Submit a new job to be run by one of the thread in the thread pool.
|
||||||
|
* The job ( thread_fn, user_data ) will be added in the queue of jobs managed
|
||||||
|
* by the thread pool, and run by the first thread that is no longer busy.
|
||||||
|
*
|
||||||
|
* @param tp the thread pool handle.
|
||||||
|
* @param job_fn Function to run. Must not be NULL.
|
||||||
|
* @param user_data User data provided to thread_fn.
|
||||||
|
* @return OPJ_TRUE if the job was successfully submitted.
|
||||||
|
*/
|
||||||
|
OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp, opj_job_fn job_fn, void* user_data);
|
||||||
|
|
||||||
|
/** Wait that no more than max_remaining_jobs jobs are remaining in the queue of
|
||||||
|
* the thread pool. The aim of this function is to avoid submitting too many
|
||||||
|
* jobs while the thread pool cannot cope fast enough with them, which would
|
||||||
|
* result potentially in out-of-memory situations with too many job descriptions
|
||||||
|
* being queued.
|
||||||
|
*
|
||||||
|
* @param tp the thread pool handle
|
||||||
|
* @param max_remaining_jobs maximum number of jobs allowed to be queued without waiting.
|
||||||
|
*/
|
||||||
|
void opj_thread_pool_wait_completion(opj_thread_pool_t* tp, int max_remaining_jobs);
|
||||||
|
|
||||||
|
/** Return the number of threads associated with the thread pool.
|
||||||
|
*
|
||||||
|
* @param tp the thread pool handle.
|
||||||
|
* @return number of threads associated with the thread pool.
|
||||||
|
*/
|
||||||
|
int opj_thread_pool_get_thread_count(opj_thread_pool_t* tp);
|
||||||
|
|
||||||
|
/** Destroy a thread pool.
|
||||||
|
* @param tp the thread pool handle.
|
||||||
|
*/
|
||||||
|
void opj_thread_pool_destroy(opj_thread_pool_t* tp);
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
#endif /* THREAD_H */
|
37
src/lib/openjp2/tls_keys.h
Normal file
37
src/lib/openjp2/tls_keys.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* The copyright in this software is being made available under the 2-clauses
|
||||||
|
* BSD License, included below. This software may be subject to other third
|
||||||
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
|
* are granted under this license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, Even Rouault
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TLS_KEYS_H
|
||||||
|
#define TLS_KEYS_H
|
||||||
|
|
||||||
|
#define OPJ_TLS_KEY_T1 0
|
||||||
|
|
||||||
|
#endif
|
6
thirdparty/liblcms2/include/lcms2.h
vendored
6
thirdparty/liblcms2/include/lcms2.h
vendored
@ -23,7 +23,7 @@
|
|||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Version 2.8beta0
|
// Version 2.8
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _lcms2_H
|
#ifndef _lcms2_H
|
||||||
@ -656,7 +656,7 @@ typedef void* cmsHTRANSFORM;
|
|||||||
// T: Pixeltype
|
// T: Pixeltype
|
||||||
// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
|
// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
|
||||||
// P: Planar? 0=Chunky, 1=Planar
|
// P: Planar? 0=Chunky, 1=Planar
|
||||||
// X: swap 16 bps endianess?
|
// X: swap 16 bps endianness?
|
||||||
// S: Do swap? ie, BGR, KYMC
|
// S: Do swap? ie, BGR, KYMC
|
||||||
// E: Extra samples
|
// E: Extra samples
|
||||||
// C: Channels (Samples per pixel)
|
// C: Channels (Samples per pixel)
|
||||||
@ -1016,7 +1016,7 @@ CMSAPI long int CMSEXPORT cmsfilelength(FILE* f);
|
|||||||
// Context handling --------------------------------------------------------------------------------------------------------
|
// Context handling --------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Each context holds its owns globals and its own plug-ins. There is a global context with the id = 0 for lecacy compatibility
|
// Each context holds its owns globals and its own plug-ins. There is a global context with the id = 0 for lecacy compatibility
|
||||||
// though using the global context is not recomended. Proper context handling makes lcms more thread-safe.
|
// though using the global context is not recommended. Proper context handling makes lcms more thread-safe.
|
||||||
|
|
||||||
typedef struct _cmsContext_struct* cmsContext;
|
typedef struct _cmsContext_struct* cmsContext;
|
||||||
|
|
||||||
|
2
thirdparty/liblcms2/include/lcms2_plugin.h
vendored
2
thirdparty/liblcms2/include/lcms2_plugin.h
vendored
@ -128,7 +128,7 @@ struct _cms_io_handler {
|
|||||||
const void* Buffer);
|
const void* Buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Endianess adjust functions
|
// Endianness adjust functions
|
||||||
CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
|
CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
|
||||||
CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
|
CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
|
||||||
CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
|
CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
|
||||||
|
49
thirdparty/liblcms2/src/cmsalpha.c
vendored
49
thirdparty/liblcms2/src/cmsalpha.c
vendored
@ -413,17 +413,12 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
|||||||
cmsUInt32Number LineCount,
|
cmsUInt32Number LineCount,
|
||||||
const cmsStride* Stride)
|
const cmsStride* Stride)
|
||||||
{
|
{
|
||||||
size_t i, j, k;
|
cmsUInt32Number i, j, k;
|
||||||
cmsUInt32Number nExtra;
|
cmsUInt32Number nExtra;
|
||||||
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
|
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
|
||||||
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
|
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
|
||||||
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
|
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
|
||||||
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
|
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
|
||||||
cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
|
|
||||||
cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];
|
|
||||||
|
|
||||||
cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
|
|
||||||
cmsUInt8Number* DestPtr[cmsMAXCHANNELS];
|
|
||||||
|
|
||||||
cmsFormatterAlphaFn copyValueFn;
|
cmsFormatterAlphaFn copyValueFn;
|
||||||
|
|
||||||
@ -431,6 +426,10 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
|||||||
if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
|
if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Exit early if in-place color-management is occurring - no need to copy extra channels to themselves.
|
||||||
|
if (p->InputFormat == p->OutputFormat && in == out)
|
||||||
|
return;
|
||||||
|
|
||||||
// Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
|
// Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
|
||||||
nExtra = T_EXTRA(p->InputFormat);
|
nExtra = T_EXTRA(p->InputFormat);
|
||||||
if (nExtra != T_EXTRA(p->OutputFormat))
|
if (nExtra != T_EXTRA(p->OutputFormat))
|
||||||
@ -447,6 +446,42 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
|||||||
// Check for conversions 8, 16, half, float, dbl
|
// Check for conversions 8, 16, half, float, dbl
|
||||||
copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
|
copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
|
||||||
|
|
||||||
|
if (nExtra == 1) { // Optimized routine for copying a single extra channel quickly
|
||||||
|
|
||||||
|
cmsUInt8Number* SourcePtr;
|
||||||
|
cmsUInt8Number* DestPtr;
|
||||||
|
|
||||||
|
cmsUInt32Number SourceStrideIncrement = 0;
|
||||||
|
cmsUInt32Number DestStrideIncrement = 0;
|
||||||
|
|
||||||
|
// The loop itself
|
||||||
|
for (i = 0; i < LineCount; i++) {
|
||||||
|
|
||||||
|
// Prepare pointers for the loop
|
||||||
|
SourcePtr = (cmsUInt8Number*)in + SourceStartingOrder[0] + SourceStrideIncrement;
|
||||||
|
DestPtr = (cmsUInt8Number*)out + DestStartingOrder[0] + DestStrideIncrement;
|
||||||
|
|
||||||
|
for (j = 0; j < PixelsPerLine; j++) {
|
||||||
|
|
||||||
|
copyValueFn(DestPtr, SourcePtr);
|
||||||
|
|
||||||
|
SourcePtr += SourceIncrements[0];
|
||||||
|
DestPtr += DestIncrements[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceStrideIncrement += Stride->BytesPerLineIn;
|
||||||
|
DestStrideIncrement += Stride->BytesPerLineOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else { // General case with more than one extra channel
|
||||||
|
|
||||||
|
cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
|
||||||
|
cmsUInt8Number* DestPtr[cmsMAXCHANNELS];
|
||||||
|
|
||||||
|
cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
|
||||||
|
cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];
|
||||||
|
|
||||||
memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
|
memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
|
||||||
memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
|
memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
|
||||||
|
|
||||||
@ -477,5 +512,7 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
|||||||
DestStrideIncrements[j] += Stride->BytesPerLineOut;
|
DestStrideIncrements[j] += Stride->BytesPerLineOut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
6
thirdparty/liblcms2/src/cmscgats.c
vendored
6
thirdparty/liblcms2/src/cmscgats.c
vendored
@ -596,7 +596,7 @@ void ReadReal(cmsIT8* it8, int inum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parses a float number
|
// Parses a float number
|
||||||
// This can not call directly atof because it uses locale dependant
|
// This can not call directly atof because it uses locale dependent
|
||||||
// parsing, while CCMX files always use . as decimal separator
|
// parsing, while CCMX files always use . as decimal separator
|
||||||
static
|
static
|
||||||
cmsFloat64Number ParseFloatNumber(const char *Buffer)
|
cmsFloat64Number ParseFloatNumber(const char *Buffer)
|
||||||
@ -1817,7 +1817,7 @@ cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number*
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------- Higer level parsing
|
// -------------------------------------------------------------- Higher level parsing
|
||||||
|
|
||||||
static
|
static
|
||||||
cmsBool DataFormatSection(cmsIT8* it8)
|
cmsBool DataFormatSection(cmsIT8* it8)
|
||||||
@ -2120,7 +2120,7 @@ cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Init usefull pointers
|
// Init useful pointers
|
||||||
|
|
||||||
static
|
static
|
||||||
void CookPointers(cmsIT8* it8)
|
void CookPointers(cmsIT8* it8)
|
||||||
|
6
thirdparty/liblcms2/src/cmscnvrt.c
vendored
6
thirdparty/liblcms2/src/cmscnvrt.c
vendored
@ -107,7 +107,7 @@ static cmsIntentsList DefaultIntents[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// A pointer to the begining of the list
|
// A pointer to the beginning of the list
|
||||||
_cmsIntentsPluginChunkType _cmsIntentsPluginChunk = { NULL };
|
_cmsIntentsPluginChunkType _cmsIntentsPluginChunk = { NULL };
|
||||||
|
|
||||||
// Duplicates the zone of memory used by the plug-in in the new context
|
// Duplicates the zone of memory used by the plug-in in the new context
|
||||||
@ -889,7 +889,7 @@ int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to pass thru K (which now is fixed)
|
// Make sure to pass through K (which now is fixed)
|
||||||
Outf[3] = LabK[3];
|
Outf[3] = LabK[3];
|
||||||
|
|
||||||
// Apply TAC if needed
|
// Apply TAC if needed
|
||||||
@ -957,7 +957,7 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
|
|||||||
memset(&bp, 0, sizeof(bp));
|
memset(&bp, 0, sizeof(bp));
|
||||||
|
|
||||||
// We need the input LUT of the last profile, assuming this one is responsible of
|
// We need the input LUT of the last profile, assuming this one is responsible of
|
||||||
// black generation. This LUT will be seached in inverse order.
|
// black generation. This LUT will be searched in inverse order.
|
||||||
bp.LabK2cmyk = _cmsReadInputLUT(hProfiles[nProfiles-1], INTENT_RELATIVE_COLORIMETRIC);
|
bp.LabK2cmyk = _cmsReadInputLUT(hProfiles[nProfiles-1], INTENT_RELATIVE_COLORIMETRIC);
|
||||||
if (bp.LabK2cmyk == NULL) goto Cleanup;
|
if (bp.LabK2cmyk == NULL) goto Cleanup;
|
||||||
|
|
||||||
|
6
thirdparty/liblcms2/src/cmserr.c
vendored
6
thirdparty/liblcms2/src/cmserr.c
vendored
@ -198,7 +198,7 @@ void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auxiliar to fill memory management functions from plugin (or context 0 defaults)
|
// Auxiliary to fill memory management functions from plugin (or context 0 defaults)
|
||||||
void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr)
|
void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr)
|
||||||
{
|
{
|
||||||
if (Plugin == NULL) {
|
if (Plugin == NULL) {
|
||||||
@ -430,14 +430,14 @@ void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size
|
|||||||
|
|
||||||
// Error logging ******************************************************************
|
// Error logging ******************************************************************
|
||||||
|
|
||||||
// There is no error handling at all. When a funtion fails, it returns proper value.
|
// There is no error handling at all. When a function fails, it returns proper value.
|
||||||
// For example, all create functions does return NULL on failure. Other return FALSE
|
// For example, all create functions does return NULL on failure. Other return FALSE
|
||||||
// It may be interesting, for the developer, to know why the function is failing.
|
// It may be interesting, for the developer, to know why the function is failing.
|
||||||
// for that reason, lcms2 does offer a logging function. This function does recive
|
// for that reason, lcms2 does offer a logging function. This function does recive
|
||||||
// a ENGLISH string with some clues on what is going wrong. You can show this
|
// a ENGLISH string with some clues on what is going wrong. You can show this
|
||||||
// info to the end user, or just create some sort of log.
|
// info to the end user, or just create some sort of log.
|
||||||
// The logging function should NOT terminate the program, as this obviously can leave
|
// The logging function should NOT terminate the program, as this obviously can leave
|
||||||
// resources. It is the programmer's responsability to check each function return code
|
// resources. It is the programmer's responsibility to check each function return code
|
||||||
// to make sure it didn't fail.
|
// to make sure it didn't fail.
|
||||||
|
|
||||||
// Error messages are limited to MAX_ERROR_MESSAGE_LEN
|
// Error messages are limited to MAX_ERROR_MESSAGE_LEN
|
||||||
|
2
thirdparty/liblcms2/src/cmsgamma.c
vendored
2
thirdparty/liblcms2/src/cmsgamma.c
vendored
@ -567,7 +567,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
|
|||||||
return Val;
|
return Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate a segmented funtion for a single value. Return -1 if no valid segment found .
|
// Evaluate a segmented function for a single value. Return -1 if no valid segment found .
|
||||||
// If fn type is 0, perform an interpolation on the table
|
// If fn type is 0, perform an interpolation on the table
|
||||||
static
|
static
|
||||||
cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R)
|
cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R)
|
||||||
|
6
thirdparty/liblcms2/src/cmsgmt.c
vendored
6
thirdparty/liblcms2/src/cmsgmt.c
vendored
@ -27,7 +27,7 @@
|
|||||||
#include "lcms2_internal.h"
|
#include "lcms2_internal.h"
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar: append a Lab identity after the given sequence of profiles
|
// Auxiliary: append a Lab identity after the given sequence of profiles
|
||||||
// and return the transform. Lab profile is closed, rest of profiles are kept open.
|
// and return the transform. Lab profile is closed, rest of profiles are kept open.
|
||||||
cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
|
cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
|
||||||
cmsUInt32Number nProfiles,
|
cmsUInt32Number nProfiles,
|
||||||
@ -172,7 +172,7 @@ cmsToneCurve* _cmsBuildKToneCurve(cmsContext ContextID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the relationship. This effectively limits the maximum accuracy to 16 bits, but
|
// Build the relationship. This effectively limits the maximum accuracy to 16 bits, but
|
||||||
// since this is used on black-preserving LUTs, we are not loosing accuracy in any case
|
// since this is used on black-preserving LUTs, we are not losing accuracy in any case
|
||||||
KTone = cmsJoinToneCurve(ContextID, in, out, nPoints);
|
KTone = cmsJoinToneCurve(ContextID, in, out, nPoints);
|
||||||
|
|
||||||
// Get rid of components
|
// Get rid of components
|
||||||
@ -278,7 +278,7 @@ int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs
|
// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs
|
||||||
// the dE obtained is then annotated on the LUT. Values truely out of gamut are clipped to dE = 0xFFFE
|
// the dE obtained is then annotated on the LUT. Values truly out of gamut are clipped to dE = 0xFFFE
|
||||||
// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well.
|
// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well.
|
||||||
//
|
//
|
||||||
// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors,
|
// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors,
|
||||||
|
2
thirdparty/liblcms2/src/cmsintrp.c
vendored
2
thirdparty/liblcms2/src/cmsintrp.c
vendored
@ -156,7 +156,7 @@ cmsInterpParams* _cmsComputeInterpParams(cmsContext ContextID, int nSamples, int
|
|||||||
int i;
|
int i;
|
||||||
cmsUInt32Number Samples[MAX_INPUT_DIMENSIONS];
|
cmsUInt32Number Samples[MAX_INPUT_DIMENSIONS];
|
||||||
|
|
||||||
// Fill the auxiliar array
|
// Fill the auxiliary array
|
||||||
for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
|
for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
|
||||||
Samples[i] = nSamples;
|
Samples[i] = nSamples;
|
||||||
|
|
||||||
|
32
thirdparty/liblcms2/src/cmsio0.c
vendored
32
thirdparty/liblcms2/src/cmsio0.c
vendored
@ -324,7 +324,7 @@ cmsUInt32Number FileRead(cmsIOHANDLER* iohandler, void *Buffer, cmsUInt32Number
|
|||||||
return nReaded;
|
return nReaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Postion file pointer in the file
|
// Position file pointer in the file
|
||||||
static
|
static
|
||||||
cmsBool FileSeek(cmsIOHANDLER* iohandler, cmsUInt32Number offset)
|
cmsBool FileSeek(cmsIOHANDLER* iohandler, cmsUInt32Number offset)
|
||||||
{
|
{
|
||||||
@ -368,6 +368,7 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha
|
|||||||
{
|
{
|
||||||
cmsIOHANDLER* iohandler = NULL;
|
cmsIOHANDLER* iohandler = NULL;
|
||||||
FILE* fm = NULL;
|
FILE* fm = NULL;
|
||||||
|
cmsInt32Number fileLen;
|
||||||
|
|
||||||
_cmsAssert(FileName != NULL);
|
_cmsAssert(FileName != NULL);
|
||||||
_cmsAssert(AccessMode != NULL);
|
_cmsAssert(AccessMode != NULL);
|
||||||
@ -384,7 +385,16 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha
|
|||||||
cmsSignalError(ContextID, cmsERROR_FILE, "File '%s' not found", FileName);
|
cmsSignalError(ContextID, cmsERROR_FILE, "File '%s' not found", FileName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
iohandler -> ReportedSize = (cmsUInt32Number) cmsfilelength(fm);
|
fileLen = cmsfilelength(fm);
|
||||||
|
if (fileLen < 0)
|
||||||
|
{
|
||||||
|
fclose(fm);
|
||||||
|
_cmsFree(ContextID, iohandler);
|
||||||
|
cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of file '%s'", FileName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
iohandler -> ReportedSize = (cmsUInt32Number) fileLen;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
@ -424,6 +434,14 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha
|
|||||||
cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream)
|
cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream)
|
||||||
{
|
{
|
||||||
cmsIOHANDLER* iohandler = NULL;
|
cmsIOHANDLER* iohandler = NULL;
|
||||||
|
cmsInt32Number fileSize;
|
||||||
|
|
||||||
|
fileSize = cmsfilelength(Stream);
|
||||||
|
if (fileSize < 0)
|
||||||
|
{
|
||||||
|
cmsSignalError(ContextID, cmsERROR_FILE, "Cannot get size of stream");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
|
iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
|
||||||
if (iohandler == NULL) return NULL;
|
if (iohandler == NULL) return NULL;
|
||||||
@ -431,7 +449,7 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* S
|
|||||||
iohandler -> ContextID = ContextID;
|
iohandler -> ContextID = ContextID;
|
||||||
iohandler -> stream = (void*) Stream;
|
iohandler -> stream = (void*) Stream;
|
||||||
iohandler -> UsedSpace = 0;
|
iohandler -> UsedSpace = 0;
|
||||||
iohandler -> ReportedSize = (cmsUInt32Number) cmsfilelength(Stream);
|
iohandler -> ReportedSize = (cmsUInt32Number) fileSize;
|
||||||
iohandler -> PhysicalFile[0] = 0;
|
iohandler -> PhysicalFile[0] = 0;
|
||||||
|
|
||||||
iohandler ->Read = FileRead;
|
iohandler ->Read = FileRead;
|
||||||
@ -623,7 +641,7 @@ cmsBool _cmsNewTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, int* NewPos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check existance
|
// Check existence
|
||||||
cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
||||||
{
|
{
|
||||||
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) (void*) hProfile;
|
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) (void*) hProfile;
|
||||||
@ -679,7 +697,7 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust endianess of the used parameters
|
// Adjust endianness of the used parameters
|
||||||
Icc -> DeviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Header.deviceClass);
|
Icc -> DeviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Header.deviceClass);
|
||||||
Icc -> ColorSpace = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.colorSpace);
|
Icc -> ColorSpace = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.colorSpace);
|
||||||
Icc -> PCS = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.pcs);
|
Icc -> PCS = (cmsColorSpaceSignature) _cmsAdjustEndianess32(Header.pcs);
|
||||||
@ -797,7 +815,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
|
|||||||
|
|
||||||
memset(&Header.reserved, 0, sizeof(Header.reserved));
|
memset(&Header.reserved, 0, sizeof(Header.reserved));
|
||||||
|
|
||||||
// Set profile ID. Endianess is always big endian
|
// Set profile ID. Endianness is always big endian
|
||||||
memmove(&Header.profileID, &Icc ->ProfileID, 16);
|
memmove(&Header.profileID, &Icc ->ProfileID, 16);
|
||||||
|
|
||||||
// Dump the header
|
// Dump the header
|
||||||
@ -1544,7 +1562,7 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
|||||||
LocalTypeHandler.ICCVersion = Icc ->Version;
|
LocalTypeHandler.ICCVersion = Icc ->Version;
|
||||||
Icc -> TagPtrs[n] = LocalTypeHandler.ReadPtr(&LocalTypeHandler, io, &ElemCount, TagSize);
|
Icc -> TagPtrs[n] = LocalTypeHandler.ReadPtr(&LocalTypeHandler, io, &ElemCount, TagSize);
|
||||||
|
|
||||||
// The tag type is supported, but something wrong happend and we cannot read the tag.
|
// The tag type is supported, but something wrong happened and we cannot read the tag.
|
||||||
// let know the user about this (although it is just a warning)
|
// let know the user about this (although it is just a warning)
|
||||||
if (Icc -> TagPtrs[n] == NULL) {
|
if (Icc -> TagPtrs[n] == NULL) {
|
||||||
|
|
||||||
|
43
thirdparty/liblcms2/src/cmsio1.c
vendored
43
thirdparty/liblcms2/src/cmsio1.c
vendored
@ -128,7 +128,7 @@ cmsBool _cmsReadCHAD(cmsMAT3* Dest, cmsHPROFILE hProfile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar, read colorants as a MAT3 structure. Used by any function that needs a matrix-shaper
|
// Auxiliary, read colorants as a MAT3 structure. Used by any function that needs a matrix-shaper
|
||||||
static
|
static
|
||||||
cmsBool ReadICCMatrixRGB2XYZ(cmsMAT3* r, cmsHPROFILE hProfile)
|
cmsBool ReadICCMatrixRGB2XYZ(cmsMAT3* r, cmsHPROFILE hProfile)
|
||||||
{
|
{
|
||||||
@ -314,7 +314,7 @@ cmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent)
|
|||||||
cmsTagSignature tagFloat;
|
cmsTagSignature tagFloat;
|
||||||
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
||||||
|
|
||||||
// On named color, take the appropiate tag
|
// On named color, take the appropriate tag
|
||||||
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
|
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
|
||||||
|
|
||||||
cmsPipeline* Lut;
|
cmsPipeline* Lut;
|
||||||
@ -336,9 +336,9 @@ cmsPipeline* _cmsReadInputLUT(cmsHPROFILE hProfile, int Intent)
|
|||||||
return Lut;
|
return Lut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is an attempt to reuse this funtion to retrieve the matrix-shaper as pipeline no
|
// This is an attempt to reuse this function to retrieve the matrix-shaper as pipeline no
|
||||||
// matter other LUT are present and have precedence. Intent = -1 means just this.
|
// matter other LUT are present and have precedence. Intent = -1 means just this.
|
||||||
if (Intent != -1) {
|
if (Intent >= INTENT_PERCEPTUAL && Intent <= INTENT_ABSOLUTE_COLORIMETRIC) {
|
||||||
|
|
||||||
tag16 = Device2PCS16[Intent];
|
tag16 = Device2PCS16[Intent];
|
||||||
tagFloat = Device2PCSFloat[Intent];
|
tagFloat = Device2PCSFloat[Intent];
|
||||||
@ -394,7 +394,7 @@ Error:
|
|||||||
// Check if this is a grayscale profile.
|
// Check if this is a grayscale profile.
|
||||||
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
|
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
|
||||||
|
|
||||||
// if so, build appropiate conversion tables.
|
// if so, build appropriate conversion tables.
|
||||||
// The tables are the PCS iluminant, scaled across GrayTRC
|
// The tables are the PCS iluminant, scaled across GrayTRC
|
||||||
return BuildGrayInputMatrixPipeline(hProfile);
|
return BuildGrayInputMatrixPipeline(hProfile);
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFlo
|
|||||||
if (Lut == NULL) return NULL;
|
if (Lut == NULL) return NULL;
|
||||||
|
|
||||||
// If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
|
// If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
|
||||||
// and since the formatter has already accomodated to 0..1.0, we should undo this change
|
// and since the formatter has already accommodated to 0..1.0, we should undo this change
|
||||||
if ( PCS == cmsSigLabData)
|
if ( PCS == cmsSigLabData)
|
||||||
{
|
{
|
||||||
if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
|
if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
|
||||||
@ -590,7 +590,7 @@ cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
|
|||||||
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
||||||
|
|
||||||
|
|
||||||
if (Intent != -1) {
|
if (Intent >= INTENT_PERCEPTUAL && Intent <= INTENT_ABSOLUTE_COLORIMETRIC) {
|
||||||
|
|
||||||
tag16 = PCS2Device16[Intent];
|
tag16 = PCS2Device16[Intent];
|
||||||
tagFloat = PCS2DeviceFloat[Intent];
|
tagFloat = PCS2DeviceFloat[Intent];
|
||||||
@ -651,7 +651,7 @@ Error:
|
|||||||
// Check if this is a grayscale profile.
|
// Check if this is a grayscale profile.
|
||||||
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
|
if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
|
||||||
|
|
||||||
// if so, build appropiate conversion tables.
|
// if so, build appropriate conversion tables.
|
||||||
// The tables are the PCS iluminant, scaled across GrayTRC
|
// The tables are the PCS iluminant, scaled across GrayTRC
|
||||||
return BuildGrayOutputPipeline(hProfile);
|
return BuildGrayOutputPipeline(hProfile);
|
||||||
}
|
}
|
||||||
@ -709,15 +709,21 @@ cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent)
|
|||||||
{
|
{
|
||||||
cmsPipeline* Lut;
|
cmsPipeline* Lut;
|
||||||
cmsTagTypeSignature OriginalType;
|
cmsTagTypeSignature OriginalType;
|
||||||
cmsTagSignature tag16 = Device2PCS16[Intent];
|
cmsTagSignature tag16;
|
||||||
cmsTagSignature tagFloat = Device2PCSFloat[Intent];
|
cmsTagSignature tagFloat;
|
||||||
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
cmsContext ContextID = cmsGetProfileContextID(hProfile);
|
||||||
|
|
||||||
|
|
||||||
// On named color, take the appropiate tag
|
if (Intent < INTENT_PERCEPTUAL || Intent > INTENT_ABSOLUTE_COLORIMETRIC)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
tag16 = Device2PCS16[Intent];
|
||||||
|
tagFloat = Device2PCSFloat[Intent];
|
||||||
|
|
||||||
|
// On named color, take the appropriate tag
|
||||||
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
|
if (cmsGetDeviceClass(hProfile) == cmsSigNamedColorClass) {
|
||||||
|
|
||||||
cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) cmsReadTag(hProfile, cmsSigNamedColor2Tag);
|
cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*)cmsReadTag(hProfile, cmsSigNamedColor2Tag);
|
||||||
|
|
||||||
if (nc == NULL) return NULL;
|
if (nc == NULL) return NULL;
|
||||||
|
|
||||||
@ -733,12 +739,13 @@ cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent)
|
|||||||
goto Error;
|
goto Error;
|
||||||
|
|
||||||
return Lut;
|
return Lut;
|
||||||
Error:
|
Error:
|
||||||
cmsPipelineFree(Lut);
|
cmsPipelineFree(Lut);
|
||||||
cmsFreeNamedColorList(nc);
|
cmsFreeNamedColorList(nc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
|
if (cmsIsTag(hProfile, tagFloat)) { // Float tag takes precedence
|
||||||
|
|
||||||
// Floating point LUT are always V
|
// Floating point LUT are always V
|
||||||
@ -748,7 +755,7 @@ Error:
|
|||||||
tagFloat = Device2PCSFloat[0];
|
tagFloat = Device2PCSFloat[0];
|
||||||
if (cmsIsTag(hProfile, tagFloat)) {
|
if (cmsIsTag(hProfile, tagFloat)) {
|
||||||
|
|
||||||
return cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
|
return cmsPipelineDup((cmsPipeline*)cmsReadTag(hProfile, tagFloat));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
|
if (!cmsIsTag(hProfile, tag16)) { // Is there any LUT-Based table?
|
||||||
@ -760,7 +767,7 @@ Error:
|
|||||||
// Check profile version and LUT type. Do the necessary adjustments if needed
|
// Check profile version and LUT type. Do the necessary adjustments if needed
|
||||||
|
|
||||||
// Read the tag
|
// Read the tag
|
||||||
Lut = (cmsPipeline*) cmsReadTag(hProfile, tag16);
|
Lut = (cmsPipeline*)cmsReadTag(hProfile, tag16);
|
||||||
if (Lut == NULL) return NULL;
|
if (Lut == NULL) return NULL;
|
||||||
|
|
||||||
// The profile owns the Lut, so we need to copy it
|
// The profile owns the Lut, so we need to copy it
|
||||||
@ -781,12 +788,12 @@ Error:
|
|||||||
// Here it is possible to get Lab on both sides
|
// Here it is possible to get Lab on both sides
|
||||||
|
|
||||||
if (cmsGetColorSpace(hProfile) == cmsSigLabData) {
|
if (cmsGetColorSpace(hProfile) == cmsSigLabData) {
|
||||||
if(!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
|
if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocLabV4ToV2(ContextID)))
|
||||||
goto Error2;
|
goto Error2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmsGetPCS(hProfile) == cmsSigLabData) {
|
if (cmsGetPCS(hProfile) == cmsSigLabData) {
|
||||||
if(!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
|
if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
|
||||||
goto Error2;
|
goto Error2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +928,7 @@ cmsBool _cmsWriteProfileSequence(cmsHPROFILE hProfile, const cmsSEQ* seq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar, read and duplicate a MLU if found.
|
// Auxiliary, read and duplicate a MLU if found.
|
||||||
static
|
static
|
||||||
cmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig)
|
cmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig)
|
||||||
{
|
{
|
||||||
|
2
thirdparty/liblcms2/src/cmsmtrx.c
vendored
2
thirdparty/liblcms2/src/cmsmtrx.c
vendored
@ -38,7 +38,7 @@ void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y,
|
|||||||
r -> n[VZ] = z;
|
r -> n[VZ] = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vector substraction
|
// Vector subtraction
|
||||||
void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b)
|
void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b)
|
||||||
{
|
{
|
||||||
r -> n[VX] = a -> n[VX] - b -> n[VX];
|
r -> n[VX] = a -> n[VX] - b -> n[VX];
|
||||||
|
9
thirdparty/liblcms2/src/cmsnamed.c
vendored
9
thirdparty/liblcms2/src/cmsnamed.c
vendored
@ -206,10 +206,10 @@ void strFrom16(char str[3], cmsUInt16Number n)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an ASCII entry.
|
// Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
|
||||||
cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
|
cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
|
||||||
{
|
{
|
||||||
cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString)+1;
|
cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString);
|
||||||
wchar_t* WStr;
|
wchar_t* WStr;
|
||||||
cmsBool rc;
|
cmsBool rc;
|
||||||
cmsUInt16Number Lang = strTo16(LanguageCode);
|
cmsUInt16Number Lang = strTo16(LanguageCode);
|
||||||
@ -243,8 +243,7 @@ cmsUInt32Number mywcslen(const wchar_t *s)
|
|||||||
return (cmsUInt32Number)(p - s);
|
return (cmsUInt32Number)(p - s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a wide entry. Do not add any \0 terminator (ICC1v43_2010-12.pdf page 61)
|
||||||
// Add a wide entry
|
|
||||||
cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
|
cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString)
|
||||||
{
|
{
|
||||||
cmsUInt16Number Lang = strTo16(Language);
|
cmsUInt16Number Lang = strTo16(Language);
|
||||||
@ -254,7 +253,7 @@ cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char
|
|||||||
if (mlu == NULL) return FALSE;
|
if (mlu == NULL) return FALSE;
|
||||||
if (WideString == NULL) return FALSE;
|
if (WideString == NULL) return FALSE;
|
||||||
|
|
||||||
len = (cmsUInt32Number) (mywcslen(WideString) + 1) * sizeof(wchar_t);
|
len = (cmsUInt32Number) (mywcslen(WideString)) * sizeof(wchar_t);
|
||||||
return AddMLUBlock(mlu, len, WideString, Lang, Cntry);
|
return AddMLUBlock(mlu, len, WideString, Lang, Cntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
thirdparty/liblcms2/src/cmsopt.c
vendored
4
thirdparty/liblcms2/src/cmsopt.c
vendored
@ -529,7 +529,7 @@ cmsBool PatchLUT(cmsStage* CLUT, cmsUInt16Number At[], cmsUInt16Number Value[],
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auxiliar, to see if two values are equal or very different
|
// Auxiliary, to see if two values are equal or very different
|
||||||
static
|
static
|
||||||
cmsBool WhitesAreEqual(int n, cmsUInt16Number White1[], cmsUInt16Number White2[] )
|
cmsBool WhitesAreEqual(int n, cmsUInt16Number White1[], cmsUInt16Number White2[] )
|
||||||
{
|
{
|
||||||
@ -537,7 +537,7 @@ cmsBool WhitesAreEqual(int n, cmsUInt16Number White1[], cmsUInt16Number White2[]
|
|||||||
|
|
||||||
for (i=0; i < n; i++) {
|
for (i=0; i < n; i++) {
|
||||||
|
|
||||||
if (abs(White1[i] - White2[i]) > 0xf000) return TRUE; // Values are so extremly different that the fixup should be avoided
|
if (abs(White1[i] - White2[i]) > 0xf000) return TRUE; // Values are so extremely different that the fixup should be avoided
|
||||||
if (White1[i] != White2[i]) return FALSE;
|
if (White1[i] != White2[i]) return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
2
thirdparty/liblcms2/src/cmspack.c
vendored
2
thirdparty/liblcms2/src/cmspack.c
vendored
@ -81,7 +81,7 @@ typedef struct {
|
|||||||
#define ANYFLAVOR FLAVOR_SH(1)
|
#define ANYFLAVOR FLAVOR_SH(1)
|
||||||
|
|
||||||
|
|
||||||
// Supress waning about info never being used
|
// Suppress waning about info never being used
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable : 4100)
|
#pragma warning(disable : 4100)
|
||||||
|
6
thirdparty/liblcms2/src/cmspcs.c
vendored
6
thirdparty/liblcms2/src/cmspcs.c
vendored
@ -308,7 +308,7 @@ void CMSEXPORT cmsFloat2LabEncoded(cmsUInt16Number wLab[3], const cmsCIELab* fLa
|
|||||||
wLab[2] = ab2Fix4(Lab.b);
|
wLab[2] = ab2Fix4(Lab.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auxiliar: convert to Radians
|
// Auxiliary: convert to Radians
|
||||||
static
|
static
|
||||||
cmsFloat64Number RADIANS(cmsFloat64Number deg)
|
cmsFloat64Number RADIANS(cmsFloat64Number deg)
|
||||||
{
|
{
|
||||||
@ -316,7 +316,7 @@ cmsFloat64Number RADIANS(cmsFloat64Number deg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar: atan2 but operating in degrees and returning 0 if a==b==0
|
// Auxiliary: atan2 but operating in degrees and returning 0 if a==b==0
|
||||||
static
|
static
|
||||||
cmsFloat64Number atan2deg(cmsFloat64Number a, cmsFloat64Number b)
|
cmsFloat64Number atan2deg(cmsFloat64Number a, cmsFloat64Number b)
|
||||||
{
|
{
|
||||||
@ -339,7 +339,7 @@ cmsFloat64Number atan2deg(cmsFloat64Number a, cmsFloat64Number b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar: Square
|
// Auxiliary: Square
|
||||||
static
|
static
|
||||||
cmsFloat64Number Sqr(cmsFloat64Number v)
|
cmsFloat64Number Sqr(cmsFloat64Number v)
|
||||||
{
|
{
|
||||||
|
13
thirdparty/liblcms2/src/cmsplugin.c
vendored
13
thirdparty/liblcms2/src/cmsplugin.c
vendored
@ -107,7 +107,7 @@ void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number*
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auxiliar -- read 8, 16 and 32-bit numbers
|
// Auxiliary -- read 8, 16 and 32-bit numbers
|
||||||
cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n)
|
cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n)
|
||||||
{
|
{
|
||||||
cmsUInt8Number tmp;
|
cmsUInt8Number tmp;
|
||||||
@ -172,13 +172,13 @@ cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n)
|
|||||||
|
|
||||||
_cmsAssert(io != NULL);
|
_cmsAssert(io != NULL);
|
||||||
|
|
||||||
if (io -> Read(io, &tmp, sizeof(cmsFloat32Number), 1) != 1)
|
if (io -> Read(io, &tmp, sizeof(cmsUInt32Number), 1) != 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (n != NULL) {
|
if (n != NULL) {
|
||||||
|
|
||||||
tmp = _cmsAdjustEndianess32(tmp);
|
tmp = _cmsAdjustEndianess32(tmp);
|
||||||
*n = *(cmsFloat32Number*) &tmp;
|
*n = *(cmsFloat32Number*) (void*) &tmp;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n)
|
|||||||
|
|
||||||
_cmsAssert(io != NULL);
|
_cmsAssert(io != NULL);
|
||||||
|
|
||||||
tmp = *(cmsUInt32Number*) &n;
|
tmp = *(cmsUInt32Number*) (void*) &n;
|
||||||
tmp = _cmsAdjustEndianess32(tmp);
|
tmp = _cmsAdjustEndianess32(tmp);
|
||||||
if (io -> Write(io, sizeof(cmsUInt32Number), &tmp) != 1)
|
if (io -> Write(io, sizeof(cmsUInt32Number), &tmp) != 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -485,7 +485,10 @@ cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...)
|
|||||||
va_start(args, frm);
|
va_start(args, frm);
|
||||||
|
|
||||||
len = vsnprintf((char*) Buffer, 2047, frm, args);
|
len = vsnprintf((char*) Buffer, 2047, frm, args);
|
||||||
if (len < 0) return FALSE; // Truncated, which is a fatal error for us
|
if (len < 0) {
|
||||||
|
va_end(args);
|
||||||
|
return FALSE; // Truncated, which is a fatal error for us
|
||||||
|
}
|
||||||
|
|
||||||
rc = io ->Write(io, len, Buffer);
|
rc = io ->Write(io, len, Buffer);
|
||||||
|
|
||||||
|
2
thirdparty/liblcms2/src/cmsps2.c
vendored
2
thirdparty/liblcms2/src/cmsps2.c
vendored
@ -579,7 +579,7 @@ void EmitNGamma(cmsIOHANDLER* m, int n, cmsToneCurve* g[])
|
|||||||
//
|
//
|
||||||
// Each row contains Pipeline values for all but first component. So, I
|
// Each row contains Pipeline values for all but first component. So, I
|
||||||
// detect row changing by keeping a copy of last value of first
|
// detect row changing by keeping a copy of last value of first
|
||||||
// component. -1 is used to mark begining of whole block.
|
// component. -1 is used to mark beginning of whole block.
|
||||||
|
|
||||||
static
|
static
|
||||||
int OutputValueSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
int OutputValueSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||||
|
4
thirdparty/liblcms2/src/cmssm.c
vendored
4
thirdparty/liblcms2/src/cmssm.c
vendored
@ -318,7 +318,7 @@ void CMSEXPORT cmsGBDFree(cmsHANDLE hGBD)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar to retrieve a pointer to the segmentr containing the Lab value
|
// Auxiliary to retrieve a pointer to the segmentr containing the Lab value
|
||||||
static
|
static
|
||||||
cmsGDBPoint* GetPoint(cmsGDB* gbd, const cmsCIELab* Lab, cmsSpherical* sp)
|
cmsGDBPoint* GetPoint(cmsGDB* gbd, const cmsCIELab* Lab, cmsSpherical* sp)
|
||||||
{
|
{
|
||||||
@ -330,7 +330,7 @@ cmsGDBPoint* GetPoint(cmsGDB* gbd, const cmsCIELab* Lab, cmsSpherical* sp)
|
|||||||
_cmsAssert(Lab != NULL);
|
_cmsAssert(Lab != NULL);
|
||||||
_cmsAssert(sp != NULL);
|
_cmsAssert(sp != NULL);
|
||||||
|
|
||||||
// Center L* by substracting half of its domain, that's 50
|
// Center L* by subtracting half of its domain, that's 50
|
||||||
_cmsVEC3init(&v, Lab ->L - 50.0, Lab ->a, Lab ->b);
|
_cmsVEC3init(&v, Lab ->L - 50.0, Lab ->a, Lab ->b);
|
||||||
|
|
||||||
// Convert to spherical coordinates
|
// Convert to spherical coordinates
|
||||||
|
20
thirdparty/liblcms2/src/cmstypes.c
vendored
20
thirdparty/liblcms2/src/cmstypes.c
vendored
@ -30,7 +30,7 @@
|
|||||||
// This file implements every single tag and tag type as described in the ICC spec. Some types
|
// This file implements every single tag and tag type as described in the ICC spec. Some types
|
||||||
// have been deprecated, like ncl and Data. There is no implementation for those types as there
|
// have been deprecated, like ncl and Data. There is no implementation for those types as there
|
||||||
// are no profiles holding them. The programmer can also extend this list by defining his own types
|
// are no profiles holding them. The programmer can also extend this list by defining his own types
|
||||||
// by using the appropiate plug-in. There are three types of plug ins regarding that. First type
|
// by using the appropriate plug-in. There are three types of plug ins regarding that. First type
|
||||||
// allows to define new tags using any existing type. Next plug-in type allows to define new types
|
// allows to define new tags using any existing type. Next plug-in type allows to define new types
|
||||||
// and the third one is very specific: allows to extend the number of elements in the multiprocessing
|
// and the third one is very specific: allows to extend the number of elements in the multiprocessing
|
||||||
// elements special type.
|
// elements special type.
|
||||||
@ -113,7 +113,7 @@ cmsTagTypeHandler* GetHandler(cmsTagTypeSignature sig, _cmsTagTypeLinkedList* Pl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar to convert UTF-32 to UTF-16 in some cases
|
// Auxiliary to convert UTF-32 to UTF-16 in some cases
|
||||||
static
|
static
|
||||||
cmsBool _cmsWriteWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, const wchar_t* Array)
|
cmsBool _cmsWriteWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, const wchar_t* Array)
|
||||||
{
|
{
|
||||||
@ -129,7 +129,7 @@ cmsBool _cmsWriteWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, const wchar_t*
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auxiliar to read an array of wchar_t
|
// Auxiliary to read an array of wchar_t
|
||||||
static
|
static
|
||||||
cmsBool _cmsReadWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, wchar_t* Array)
|
cmsBool _cmsReadWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, wchar_t* Array)
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ typedef cmsBool (* PositionTableEntryFn)(struct _cms_typehandler_struct* self,
|
|||||||
cmsUInt32Number n,
|
cmsUInt32Number n,
|
||||||
cmsUInt32Number SizeOfTag);
|
cmsUInt32Number SizeOfTag);
|
||||||
|
|
||||||
// Helper function to deal with position tables as decribed in ICC spec 4.3
|
// Helper function to deal with position tables as described in ICC spec 4.3
|
||||||
// A table of n elements is readed, where first comes n records containing offsets and sizes and
|
// A table of n elements is readed, where first comes n records containing offsets and sizes and
|
||||||
// then a block containing the data itself. This allows to reuse same data in more than one entry
|
// then a block containing the data itself. This allows to reuse same data in more than one entry
|
||||||
static
|
static
|
||||||
@ -994,7 +994,7 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tell the real text len including the null terminator and padding
|
// Tell the real text len including the null terminator and padding
|
||||||
len_text = strlen(Text) + 1;
|
len_text = (cmsUInt32Number) strlen(Text) + 1;
|
||||||
// Compute an total tag size requirement
|
// Compute an total tag size requirement
|
||||||
len_tag_requirement = (8+4+len_text+4+4+2*len_text+2+1+67);
|
len_tag_requirement = (8+4+len_text+4+4+2*len_text+2+1+67);
|
||||||
len_aligned = _cmsALIGNLONG(len_tag_requirement);
|
len_aligned = _cmsALIGNLONG(len_tag_requirement);
|
||||||
@ -1474,7 +1474,7 @@ void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU
|
|||||||
LargestPosition = EndOfThisString;
|
LargestPosition = EndOfThisString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now read the remaining of tag and fill all strings. Substract the directory
|
// Now read the remaining of tag and fill all strings. Subtract the directory
|
||||||
SizeOfTag = (LargestPosition * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
|
SizeOfTag = (LargestPosition * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
|
||||||
if (SizeOfTag == 0)
|
if (SizeOfTag == 0)
|
||||||
{
|
{
|
||||||
@ -3609,7 +3609,7 @@ country varies for each element:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar, read an string specified as count + string
|
// Auxiliary, read an string specified as count + string
|
||||||
static
|
static
|
||||||
cmsBool ReadCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, cmsUInt32Number* SizeOfTag, const char* Section)
|
cmsBool ReadCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, cmsUInt32Number* SizeOfTag, const char* Section)
|
||||||
{
|
{
|
||||||
@ -4312,13 +4312,13 @@ Error:
|
|||||||
static
|
static
|
||||||
cmsBool Type_MPEclut_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
|
cmsBool Type_MPEclut_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
|
||||||
{
|
{
|
||||||
cmsUInt8Number Dimensions8[16];
|
cmsUInt8Number Dimensions8[16]; // 16 because the spec says 16 and not max number of channels
|
||||||
cmsUInt32Number i;
|
cmsUInt32Number i;
|
||||||
cmsStage* mpe = (cmsStage*) Ptr;
|
cmsStage* mpe = (cmsStage*) Ptr;
|
||||||
_cmsStageCLutData* clut = (_cmsStageCLutData*) mpe ->Data;
|
_cmsStageCLutData* clut = (_cmsStageCLutData*) mpe ->Data;
|
||||||
|
|
||||||
// Check for maximum number of channels
|
// Check for maximum number of channels supported by lcms
|
||||||
if (mpe -> InputChannels > 15) return FALSE;
|
if (mpe -> InputChannels > MAX_INPUT_DIMENSIONS) return FALSE;
|
||||||
|
|
||||||
// Only floats are supported in MPE
|
// Only floats are supported in MPE
|
||||||
if (clut ->HasFloatValues == FALSE) return FALSE;
|
if (clut ->HasFloatValues == FALSE) return FALSE;
|
||||||
|
9
thirdparty/liblcms2/src/cmsvirt.c
vendored
9
thirdparty/liblcms2/src/cmsvirt.c
vendored
@ -1138,15 +1138,20 @@ cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat
|
|||||||
// If no way, then force CLUT that for sure can be written
|
// If no way, then force CLUT that for sure can be written
|
||||||
if (AllowedLUT == NULL) {
|
if (AllowedLUT == NULL) {
|
||||||
|
|
||||||
|
cmsStage* FirstStage;
|
||||||
|
cmsStage* LastStage;
|
||||||
|
|
||||||
dwFlags |= cmsFLAGS_FORCE_CLUT;
|
dwFlags |= cmsFLAGS_FORCE_CLUT;
|
||||||
_cmsOptimizePipeline(ContextID, &LUT, xform ->RenderingIntent, &FrmIn, &FrmOut, &dwFlags);
|
_cmsOptimizePipeline(ContextID, &LUT, xform ->RenderingIntent, &FrmIn, &FrmOut, &dwFlags);
|
||||||
|
|
||||||
// Put identity curves if needed
|
// Put identity curves if needed
|
||||||
if (cmsPipelineGetPtrToFirstStage(LUT) ->Type != cmsSigCurveSetElemType)
|
FirstStage = cmsPipelineGetPtrToFirstStage(LUT);
|
||||||
|
if (FirstStage != NULL && FirstStage ->Type != cmsSigCurveSetElemType)
|
||||||
if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCurves(ContextID, ChansIn)))
|
if (!cmsPipelineInsertStage(LUT, cmsAT_BEGIN, _cmsStageAllocIdentityCurves(ContextID, ChansIn)))
|
||||||
goto Error;
|
goto Error;
|
||||||
|
|
||||||
if (cmsPipelineGetPtrToLastStage(LUT) ->Type != cmsSigCurveSetElemType)
|
LastStage = cmsPipelineGetPtrToLastStage(LUT);
|
||||||
|
if (LastStage != NULL && LastStage ->Type != cmsSigCurveSetElemType)
|
||||||
if (!cmsPipelineInsertStage(LUT, cmsAT_END, _cmsStageAllocIdentityCurves(ContextID, ChansOut)))
|
if (!cmsPipelineInsertStage(LUT, cmsAT_END, _cmsStageAllocIdentityCurves(ContextID, ChansOut)))
|
||||||
goto Error;
|
goto Error;
|
||||||
|
|
||||||
|
2
thirdparty/liblcms2/src/cmsxform.c
vendored
2
thirdparty/liblcms2/src/cmsxform.c
vendored
@ -413,7 +413,7 @@ void PrecalculatedXFORM(_cmsTRANSFORM* p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auxiliar: Handle precalculated gamut check. The retrieval of context may be alittle bit slow, but this function is not critical.
|
// Auxiliary: Handle precalculated gamut check. The retrieval of context may be alittle bit slow, but this function is not critical.
|
||||||
static
|
static
|
||||||
void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
|
void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
|
||||||
const cmsUInt16Number wIn[],
|
const cmsUInt16Number wIn[],
|
||||||
|
2
thirdparty/liblcms2/src/lcms2_internal.h
vendored
2
thirdparty/liblcms2/src/lcms2_internal.h
vendored
@ -739,7 +739,7 @@ typedef struct _cms_iccprofile_struct {
|
|||||||
// Dictionary
|
// Dictionary
|
||||||
cmsUInt32Number TagCount;
|
cmsUInt32Number TagCount;
|
||||||
cmsTagSignature TagNames[MAX_TABLE_TAG];
|
cmsTagSignature TagNames[MAX_TABLE_TAG];
|
||||||
cmsTagSignature TagLinked[MAX_TABLE_TAG]; // The tag to wich is linked (0=none)
|
cmsTagSignature TagLinked[MAX_TABLE_TAG]; // The tag to which is linked (0=none)
|
||||||
cmsUInt32Number TagSizes[MAX_TABLE_TAG]; // Size on disk
|
cmsUInt32Number TagSizes[MAX_TABLE_TAG]; // Size on disk
|
||||||
cmsUInt32Number TagOffsets[MAX_TABLE_TAG];
|
cmsUInt32Number TagOffsets[MAX_TABLE_TAG];
|
||||||
cmsBool TagSaveAsRaw[MAX_TABLE_TAG]; // True to write uncooked
|
cmsBool TagSaveAsRaw[MAX_TABLE_TAG]; // True to write uncooked
|
||||||
|
32
thirdparty/libpng/LICENSE
vendored
32
thirdparty/libpng/LICENSE
vendored
@ -10,7 +10,7 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
|
libpng versions 1.0.7, July 1, 2000 through 1.6.25, September 1, 2016 are
|
||||||
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||||
derived from libpng-1.0.6, and are distributed according to the same
|
derived from libpng-1.0.6, and are distributed according to the same
|
||||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@ -32,6 +32,10 @@ and with the following additions to the disclaimer:
|
|||||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||||
the user.
|
the user.
|
||||||
|
|
||||||
|
Some files in the "contrib" directory and some configure-generated
|
||||||
|
files that are distributed with libpng have other copyright owners and
|
||||||
|
are released under other open source licenses.
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||||
libpng-0.96, and are distributed according to the same disclaimer and
|
libpng-0.96, and are distributed according to the same disclaimer and
|
||||||
@ -55,6 +59,9 @@ Contributing Authors:
|
|||||||
Greg Roelofs
|
Greg Roelofs
|
||||||
Tom Tanner
|
Tom Tanner
|
||||||
|
|
||||||
|
Some files in the "scripts" directory have other copyright owners
|
||||||
|
but are released under this license.
|
||||||
|
|
||||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
|
||||||
@ -95,18 +102,29 @@ appreciated.
|
|||||||
|
|
||||||
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||||
|
|
||||||
A "png_get_copyright" function is available, for convenient use in "about"
|
TRADEMARK:
|
||||||
boxes and the like:
|
|
||||||
|
|
||||||
printf("%s", png_get_copyright(NULL));
|
The name "libpng" has not been registered by the Copyright owner
|
||||||
|
as a trademark in any jurisdiction. However, because libpng has
|
||||||
|
been distributed and maintained world-wide, continually since 1995,
|
||||||
|
the Copyright owner claims "common-law trademark protection" in any
|
||||||
|
jurisdiction where common-law trademark is recognized.
|
||||||
|
|
||||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
OSI CERTIFICATION:
|
||||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
|
||||||
|
|
||||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||||
a certification mark of the Open Source Initiative. OSI has not addressed
|
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||||
the additional disclaimers inserted at version 1.0.7.
|
the additional disclaimers inserted at version 1.0.7.
|
||||||
|
|
||||||
|
EXPORT CONTROL:
|
||||||
|
|
||||||
|
The Copyright owner believes that the Export Control Classification
|
||||||
|
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||||
|
controls or International Traffic in Arms Regulations (ITAR) because
|
||||||
|
it is open source, publicly available software, that does not contain
|
||||||
|
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
||||||
|
734.7(b).
|
||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
January 15, 2016
|
September 1, 2016
|
||||||
|
76
thirdparty/libpng/png.c
vendored
76
thirdparty/libpng/png.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "pngpriv.h"
|
#include "pngpriv.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef png_libpng_version_1_6_21 Your_png_h_is_not_version_1_6_21;
|
typedef png_libpng_version_1_6_25 Your_png_h_is_not_version_1_6_25;
|
||||||
|
|
||||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||||
* of the PNG file signature. If the PNG data is embedded into another
|
* of the PNG file signature. If the PNG data is embedded into another
|
||||||
@ -775,14 +775,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.6.21 - January 15, 2016" PNG_STRING_NEWLINE \
|
"libpng version 1.6.25 - September 1, 2016" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
|
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
|
||||||
PNG_STRING_NEWLINE \
|
PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||||
PNG_STRING_NEWLINE;
|
PNG_STRING_NEWLINE;
|
||||||
# else
|
# else
|
||||||
return "libpng version 1.6.21 - January 15, 2016\
|
return "libpng version 1.6.25 - September 1, 2016\
|
||||||
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\
|
Copyright (c) 1996-1997 Andreas Dilger\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||||
@ -1931,8 +1931,8 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
static const png_byte D50_nCIEXYZ[12] =
|
static const png_byte D50_nCIEXYZ[12] =
|
||||||
{ 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
|
{ 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
|
||||||
|
|
||||||
int /* PRIVATE */
|
static int /* bool */
|
||||||
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||||
png_const_charp name, png_uint_32 profile_length)
|
png_const_charp name, png_uint_32 profile_length)
|
||||||
{
|
{
|
||||||
if (profile_length < 132)
|
if (profile_length < 132)
|
||||||
@ -1942,6 +1942,40 @@ png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||||
|
int /* PRIVATE */
|
||||||
|
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||||
|
png_const_charp name, png_uint_32 profile_length)
|
||||||
|
{
|
||||||
|
if (!icc_check_length(png_ptr, colorspace, name, profile_length))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* This needs to be here because the 'normal' check is in
|
||||||
|
* png_decompress_chunk, yet this happens after the attempt to
|
||||||
|
* png_malloc_base the required data. We only need this on read; on write
|
||||||
|
* the caller supplies the profile buffer so libpng doesn't allocate it. See
|
||||||
|
* the call to icc_check_length below (the write case).
|
||||||
|
*/
|
||||||
|
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
|
else if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||||
|
png_ptr->user_chunk_malloc_max < profile_length)
|
||||||
|
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||||
|
"exceeds application limits");
|
||||||
|
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
|
||||||
|
else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length)
|
||||||
|
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||||
|
"exceeds libpng limits");
|
||||||
|
# else /* !SET_USER_LIMITS */
|
||||||
|
/* This will get compiled out on all 32-bit and better systems. */
|
||||||
|
else if (PNG_SIZE_MAX < profile_length)
|
||||||
|
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||||
|
"exceeds system limits");
|
||||||
|
# endif /* !SET_USER_LIMITS */
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif /* READ_iCCP */
|
||||||
|
|
||||||
int /* PRIVATE */
|
int /* PRIVATE */
|
||||||
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||||
png_const_charp name, png_uint_32 profile_length,
|
png_const_charp name, png_uint_32 profile_length,
|
||||||
@ -2354,7 +2388,6 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||||||
|
|
||||||
return 0; /* no match */
|
return 0; /* no match */
|
||||||
}
|
}
|
||||||
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
|
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_icc_set_sRGB(png_const_structrp png_ptr,
|
png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||||
@ -2363,12 +2396,11 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
|
|||||||
/* Is this profile one of the known ICC sRGB profiles? If it is, just set
|
/* Is this profile one of the known ICC sRGB profiles? If it is, just set
|
||||||
* the sRGB information.
|
* the sRGB information.
|
||||||
*/
|
*/
|
||||||
#if PNG_sRGB_PROFILE_CHECKS >= 0
|
|
||||||
if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
|
if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
|
||||||
#endif
|
|
||||||
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
|
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
|
||||||
(int)/*already checked*/png_get_uint_32(profile+64));
|
(int)/*already checked*/png_get_uint_32(profile+64));
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
|
||||||
#endif /* sRGB */
|
#endif /* sRGB */
|
||||||
|
|
||||||
int /* PRIVATE */
|
int /* PRIVATE */
|
||||||
@ -2379,13 +2411,13 @@ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
||||||
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
|
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
|
||||||
color_type) != 0 &&
|
color_type) != 0 &&
|
||||||
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
|
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
|
||||||
profile) != 0)
|
profile) != 0)
|
||||||
{
|
{
|
||||||
# ifdef PNG_sRGB_SUPPORTED
|
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||||
/* If no sRGB support, don't try storing sRGB information */
|
/* If no sRGB support, don't try storing sRGB information */
|
||||||
png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
|
png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
|
||||||
# endif
|
# endif
|
||||||
@ -4092,9 +4124,9 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||||||
|
|
||||||
/* Remove any existing table; this copes with multiple calls to
|
/* Remove any existing table; this copes with multiple calls to
|
||||||
* png_read_update_info. The warning is because building the gamma tables
|
* png_read_update_info. The warning is because building the gamma tables
|
||||||
* multiple times is a performance hit - it's harmless but the ability to call
|
* multiple times is a performance hit - it's harmless but the ability to
|
||||||
* png_read_update_info() multiple times is new in 1.5.6 so it seems sensible
|
* call png_read_update_info() multiple times is new in 1.5.6 so it seems
|
||||||
* to warn if the app introduces such a hit.
|
* sensible to warn if the app introduces such a hit.
|
||||||
*/
|
*/
|
||||||
if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
|
if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
|
||||||
{
|
{
|
||||||
@ -4105,7 +4137,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||||||
if (bit_depth <= 8)
|
if (bit_depth <= 8)
|
||||||
{
|
{
|
||||||
png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
|
png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
|
||||||
png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
|
png_ptr->screen_gamma > 0 ?
|
||||||
|
png_reciprocal2(png_ptr->colorspace.gamma,
|
||||||
png_ptr->screen_gamma) : PNG_FP_1);
|
png_ptr->screen_gamma) : PNG_FP_1);
|
||||||
|
|
||||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||||
@ -4117,7 +4150,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||||||
png_reciprocal(png_ptr->colorspace.gamma));
|
png_reciprocal(png_ptr->colorspace.gamma));
|
||||||
|
|
||||||
png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
|
png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
|
||||||
png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
|
png_ptr->screen_gamma > 0 ?
|
||||||
|
png_reciprocal(png_ptr->screen_gamma) :
|
||||||
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
|
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
|
||||||
}
|
}
|
||||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||||
@ -4148,8 +4182,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||||||
* pow(iv, gamma).
|
* pow(iv, gamma).
|
||||||
*
|
*
|
||||||
* Thus the gamma table consists of up to 256 256-entry tables. The table
|
* Thus the gamma table consists of up to 256 256-entry tables. The table
|
||||||
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
|
* is selected by the (8-gamma_shift) most significant of the low 8 bits
|
||||||
* the color value then indexed by the upper 8 bits:
|
* of the color value then indexed by the upper 8 bits:
|
||||||
*
|
*
|
||||||
* table[low bits][high 8 bits]
|
* table[low bits][high 8 bits]
|
||||||
*
|
*
|
||||||
@ -4182,8 +4216,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||||||
|
|
||||||
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
|
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
|
||||||
* PNG_COMPOSE). This effectively smashed the background calculation for
|
* PNG_COMPOSE). This effectively smashed the background calculation for
|
||||||
* 16-bit output because the 8-bit table assumes the result will be reduced
|
* 16-bit output because the 8-bit table assumes the result will be
|
||||||
* to 8 bits.
|
* reduced to 8 bits.
|
||||||
*/
|
*/
|
||||||
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
|
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
|
||||||
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
|
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
|
||||||
|
278
thirdparty/libpng/png.h
vendored
278
thirdparty/libpng/png.h
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.6.21, January 15, 2016
|
* libpng version 1.6.25, September 1, 2016
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@ -12,7 +12,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.6.21, January 15, 2016:
|
* libpng versions 0.97, January 1998, through 1.6.25, September 1, 2016:
|
||||||
* Glenn Randers-Pehrson.
|
* Glenn Randers-Pehrson.
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*/
|
*/
|
||||||
@ -25,7 +25,11 @@
|
|||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
|
* Some files in the "contrib" directory and some configure-generated
|
||||||
|
* files that are distributed with libpng have other copyright owners and
|
||||||
|
* are released under other open source licenses.
|
||||||
|
*
|
||||||
|
* libpng versions 1.0.7, July 1, 2000 through 1.6.25, September 1, 2016 are
|
||||||
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||||
* derived from libpng-1.0.6, and are distributed according to the same
|
* derived from libpng-1.0.6, and are distributed according to the same
|
||||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@ -37,6 +41,7 @@
|
|||||||
* Cosmin Truta
|
* Cosmin Truta
|
||||||
* Gilles Vollant
|
* Gilles Vollant
|
||||||
* James Yu
|
* James Yu
|
||||||
|
* Mandar Sahastrabuddhe
|
||||||
*
|
*
|
||||||
* and with the following additions to the disclaimer:
|
* and with the following additions to the disclaimer:
|
||||||
*
|
*
|
||||||
@ -47,6 +52,10 @@
|
|||||||
* risk of satisfactory quality, performance, accuracy, and effort is with
|
* risk of satisfactory quality, performance, accuracy, and effort is with
|
||||||
* the user.
|
* the user.
|
||||||
*
|
*
|
||||||
|
* Some files in the "contrib" directory have other copyright owners and
|
||||||
|
* are released under other open source licenses.
|
||||||
|
*
|
||||||
|
*
|
||||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||||
* libpng-0.96, and are distributed according to the same disclaimer and
|
* libpng-0.96, and are distributed according to the same disclaimer and
|
||||||
@ -57,6 +66,9 @@
|
|||||||
* Glenn Randers-Pehrson
|
* Glenn Randers-Pehrson
|
||||||
* Willem van Schaik
|
* Willem van Schaik
|
||||||
*
|
*
|
||||||
|
* Some files in the "scripts" directory have different copyright owners
|
||||||
|
* but are also released under this license.
|
||||||
|
*
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||||
* and are distributed according to the same disclaimer and license as
|
* and are distributed according to the same disclaimer and license as
|
||||||
@ -70,6 +82,9 @@
|
|||||||
* Greg Roelofs
|
* Greg Roelofs
|
||||||
* Tom Tanner
|
* Tom Tanner
|
||||||
*
|
*
|
||||||
|
* Some files in the "scripts" directory have other copyright owners
|
||||||
|
* but are released under this license.
|
||||||
|
*
|
||||||
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
*
|
*
|
||||||
@ -109,6 +124,29 @@
|
|||||||
* appreciated.
|
* appreciated.
|
||||||
*
|
*
|
||||||
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||||
|
*
|
||||||
|
* TRADEMARK:
|
||||||
|
*
|
||||||
|
* The name "libpng" has not been registered by the Copyright owner
|
||||||
|
* as a trademark in any jurisdiction. However, because libpng has
|
||||||
|
* been distributed and maintained world-wide, continually since 1995,
|
||||||
|
* the Copyright owner claims "common-law trademark protection" in any
|
||||||
|
* jurisdiction where common-law trademark is recognized.
|
||||||
|
*
|
||||||
|
* OSI CERTIFICATION:
|
||||||
|
*
|
||||||
|
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||||
|
* a certification mark of the Open Source Initiative. OSI has not addressed
|
||||||
|
* the additional disclaimers inserted at version 1.0.7.
|
||||||
|
*
|
||||||
|
* EXPORT CONTROL:
|
||||||
|
*
|
||||||
|
* The Copyright owner believes that the Export Control Classification
|
||||||
|
* Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||||
|
* controls or International Traffic in Arms Regulations (ITAR) because
|
||||||
|
* it is open source, publicly available software, that does not contain
|
||||||
|
* any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
||||||
|
* 734.7(b).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -121,12 +159,6 @@
|
|||||||
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
|
||||||
* a certification mark of the Open Source Initiative. OSI has not addressed
|
|
||||||
* the additional disclaimers inserted at version 1.0.7.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The contributing authors would like to thank all those who helped
|
* The contributing authors would like to thank all those who helped
|
||||||
* with testing, bug fixes, and patience. This wouldn't have been
|
* with testing, bug fixes, and patience. This wouldn't have been
|
||||||
@ -182,11 +214,11 @@
|
|||||||
* ...
|
* ...
|
||||||
* 1.0.19 10 10019 10.so.0.19[.0]
|
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.2.53 13 10253 12.so.0.53[.0]
|
* 1.2.56 13 10256 12.so.0.56[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.5.23 15 10523 15.so.15.23[.0]
|
* 1.5.27 15 10527 15.so.15.27[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.6.21 16 10621 16.so.16.21[.0]
|
* 1.6.25 16 10625 16.so.16.25[.0]
|
||||||
*
|
*
|
||||||
* Henceforth the source version will match the shared-library major
|
* Henceforth the source version will match the shared-library major
|
||||||
* and minor numbers; the shared-library major version number will be
|
* and minor numbers; the shared-library major version number will be
|
||||||
@ -214,13 +246,13 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* January 15, 2016
|
* September 1, 2016
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
*
|
*
|
||||||
* This is your unofficial assurance that libpng from version 0.71 and
|
* This is your unofficial assurance that libpng from version 0.71 and
|
||||||
* upward through 1.6.21 are Y2K compliant. It is my belief that
|
* upward through 1.6.25 are Y2K compliant. It is my belief that
|
||||||
* earlier versions were also Y2K compliant.
|
* earlier versions were also Y2K compliant.
|
||||||
*
|
*
|
||||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||||
@ -282,9 +314,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.6.21"
|
#define PNG_LIBPNG_VER_STRING "1.6.25"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.25 - September 1, 2016\n"
|
||||||
" libpng version 1.6.21 - January 15, 2016\n"
|
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 16
|
#define PNG_LIBPNG_VER_SONUM 16
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||||
@ -292,7 +323,7 @@
|
|||||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||||
#define PNG_LIBPNG_VER_MAJOR 1
|
#define PNG_LIBPNG_VER_MAJOR 1
|
||||||
#define PNG_LIBPNG_VER_MINOR 6
|
#define PNG_LIBPNG_VER_MINOR 6
|
||||||
#define PNG_LIBPNG_VER_RELEASE 21
|
#define PNG_LIBPNG_VER_RELEASE 25
|
||||||
|
|
||||||
/* This should match the numeric part of the final component of
|
/* This should match the numeric part of the final component of
|
||||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||||
@ -323,20 +354,20 @@
|
|||||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||||
*/
|
*/
|
||||||
#define PNG_LIBPNG_VER 10621 /* 1.6.21 */
|
#define PNG_LIBPNG_VER 10625 /* 1.6.25 */
|
||||||
|
|
||||||
/* Library configuration: these options cannot be changed after
|
/* Library configuration: these options cannot be changed after
|
||||||
* the library has been built.
|
* the library has been built.
|
||||||
*/
|
*/
|
||||||
#ifndef PNGLCONF_H
|
#ifndef PNGLCONF_H
|
||||||
/* If pnglibconf.h is missing, you can
|
/* If pnglibconf.h is missing, you can
|
||||||
* copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
|
* copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
|
||||||
*/
|
*/
|
||||||
# include "pnglibconf.h"
|
# include "pnglibconf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_VERSION_INFO_ONLY
|
#ifndef PNG_VERSION_INFO_ONLY
|
||||||
/* Machine specific configuration. */
|
/* Machine specific configuration. */
|
||||||
# include "pngconf.h"
|
# include "pngconf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -433,7 +464,7 @@ extern "C" {
|
|||||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||||
* do not agree upon the version number.
|
* do not agree upon the version number.
|
||||||
*/
|
*/
|
||||||
typedef char* png_libpng_version_1_6_21;
|
typedef char* png_libpng_version_1_6_25;
|
||||||
|
|
||||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||||
*
|
*
|
||||||
@ -734,24 +765,22 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
|
|||||||
* data in the info_struct to be written into the output file. The values
|
* data in the info_struct to be written into the output file. The values
|
||||||
* of the PNG_INFO_<chunk> defines should NOT be changed.
|
* of the PNG_INFO_<chunk> defines should NOT be changed.
|
||||||
*/
|
*/
|
||||||
#define PNG_INFO_gAMA 0x0001
|
#define PNG_INFO_gAMA 0x0001U
|
||||||
#define PNG_INFO_sBIT 0x0002
|
#define PNG_INFO_sBIT 0x0002U
|
||||||
#define PNG_INFO_cHRM 0x0004
|
#define PNG_INFO_cHRM 0x0004U
|
||||||
#define PNG_INFO_PLTE 0x0008
|
#define PNG_INFO_PLTE 0x0008U
|
||||||
#define PNG_INFO_tRNS 0x0010
|
#define PNG_INFO_tRNS 0x0010U
|
||||||
#define PNG_INFO_bKGD 0x0020
|
#define PNG_INFO_bKGD 0x0020U
|
||||||
#define PNG_INFO_hIST 0x0040
|
#define PNG_INFO_hIST 0x0040U
|
||||||
#define PNG_INFO_pHYs 0x0080
|
#define PNG_INFO_pHYs 0x0080U
|
||||||
#define PNG_INFO_oFFs 0x0100
|
#define PNG_INFO_oFFs 0x0100U
|
||||||
#define PNG_INFO_tIME 0x0200
|
#define PNG_INFO_tIME 0x0200U
|
||||||
#define PNG_INFO_pCAL 0x0400
|
#define PNG_INFO_pCAL 0x0400U
|
||||||
#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
|
#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */
|
||||||
#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
|
#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */
|
||||||
#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
|
#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */
|
||||||
#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
|
#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
|
||||||
#if INT_MAX >= 0x8000 /* else this might break */
|
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
|
||||||
#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is used for the transformation routines, as some of them
|
/* This is used for the transformation routines, as some of them
|
||||||
* change these values for the row. It also should enable using
|
* change these values for the row. It also should enable using
|
||||||
@ -1322,7 +1351,7 @@ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
|
#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
|
||||||
/* Strip the second byte of information from a 16-bit depth file. */
|
/* Strip the second byte of information from a 16-bit depth file. */
|
||||||
PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
|
PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
|
||||||
#endif
|
#endif
|
||||||
@ -1473,8 +1502,8 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
|||||||
#define PNG_FILTER_UP 0x20
|
#define PNG_FILTER_UP 0x20
|
||||||
#define PNG_FILTER_AVG 0x40
|
#define PNG_FILTER_AVG 0x40
|
||||||
#define PNG_FILTER_PAETH 0x80
|
#define PNG_FILTER_PAETH 0x80
|
||||||
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
|
#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP)
|
||||||
PNG_FILTER_AVG | PNG_FILTER_PAETH)
|
#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH)
|
||||||
|
|
||||||
/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
|
/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
|
||||||
* These defines should NOT be changed.
|
* These defines should NOT be changed.
|
||||||
@ -1751,21 +1780,21 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
|
|||||||
#define PNG_SET_WILL_FREE_DATA 1
|
#define PNG_SET_WILL_FREE_DATA 1
|
||||||
#define PNG_USER_WILL_FREE_DATA 2
|
#define PNG_USER_WILL_FREE_DATA 2
|
||||||
/* Flags for png_ptr->free_me and info_ptr->free_me */
|
/* Flags for png_ptr->free_me and info_ptr->free_me */
|
||||||
#define PNG_FREE_HIST 0x0008
|
#define PNG_FREE_HIST 0x0008U
|
||||||
#define PNG_FREE_ICCP 0x0010
|
#define PNG_FREE_ICCP 0x0010U
|
||||||
#define PNG_FREE_SPLT 0x0020
|
#define PNG_FREE_SPLT 0x0020U
|
||||||
#define PNG_FREE_ROWS 0x0040
|
#define PNG_FREE_ROWS 0x0040U
|
||||||
#define PNG_FREE_PCAL 0x0080
|
#define PNG_FREE_PCAL 0x0080U
|
||||||
#define PNG_FREE_SCAL 0x0100
|
#define PNG_FREE_SCAL 0x0100U
|
||||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
# define PNG_FREE_UNKN 0x0200
|
# define PNG_FREE_UNKN 0x0200U
|
||||||
#endif
|
#endif
|
||||||
/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */
|
/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */
|
||||||
#define PNG_FREE_PLTE 0x1000
|
#define PNG_FREE_PLTE 0x1000U
|
||||||
#define PNG_FREE_TRNS 0x2000
|
#define PNG_FREE_TRNS 0x2000U
|
||||||
#define PNG_FREE_TEXT 0x4000
|
#define PNG_FREE_TEXT 0x4000U
|
||||||
#define PNG_FREE_ALL 0x7fff
|
#define PNG_FREE_ALL 0x7fffU
|
||||||
#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
|
#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
|
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
|
||||||
@ -2271,8 +2300,10 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
|||||||
* except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
|
* except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
|
||||||
* be processed by libpng.
|
* be processed by libpng.
|
||||||
*/
|
*/
|
||||||
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
|
PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
|
||||||
int keep, png_const_bytep chunk_list, int num_chunks));
|
int keep, png_const_bytep chunk_list, int num_chunks));
|
||||||
|
#endif /* HANDLE_AS_UNKNOWN */
|
||||||
|
|
||||||
/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
|
/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
|
||||||
* the result is therefore true (non-zero) if special handling is required,
|
* the result is therefore true (non-zero) if special handling is required,
|
||||||
@ -2280,7 +2311,7 @@ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
|
|||||||
*/
|
*/
|
||||||
PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
|
PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
|
||||||
png_const_bytep chunk_name));
|
png_const_bytep chunk_name));
|
||||||
#endif
|
#endif /* SET_UNKNOWN_CHUNKS */
|
||||||
|
|
||||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
|
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
|
||||||
@ -2502,18 +2533,22 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
|||||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||||
|
|
||||||
# define png_composite(composite, fg, alpha, bg) \
|
# define png_composite(composite, fg, alpha, bg) \
|
||||||
{ png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
|
{ \
|
||||||
|
png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
|
||||||
* (png_uint_16)(alpha) \
|
* (png_uint_16)(alpha) \
|
||||||
+ (png_uint_16)(bg)*(png_uint_16)(255 \
|
+ (png_uint_16)(bg)*(png_uint_16)(255 \
|
||||||
- (png_uint_16)(alpha)) + 128); \
|
- (png_uint_16)(alpha)) + 128); \
|
||||||
(composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
|
(composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
|
||||||
|
}
|
||||||
|
|
||||||
# define png_composite_16(composite, fg, alpha, bg) \
|
# define png_composite_16(composite, fg, alpha, bg) \
|
||||||
{ png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
|
{ \
|
||||||
|
png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
|
||||||
* (png_uint_32)(alpha) \
|
* (png_uint_32)(alpha) \
|
||||||
+ (png_uint_32)(bg)*(65535 \
|
+ (png_uint_32)(bg)*(65535 \
|
||||||
- (png_uint_32)(alpha)) + 32768); \
|
- (png_uint_32)(alpha)) + 32768); \
|
||||||
(composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
|
(composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
|
||||||
|
}
|
||||||
|
|
||||||
#else /* Standard method using integer division */
|
#else /* Standard method using integer division */
|
||||||
|
|
||||||
@ -2581,7 +2616,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
|||||||
? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
|
? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
|
||||||
: (png_int_32)png_get_uint_32(buf)))
|
: (png_int_32)png_get_uint_32(buf)))
|
||||||
|
|
||||||
/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
|
/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
|
||||||
* but defining a macro name prefixed with PNG_PREFIX.
|
* but defining a macro name prefixed with PNG_PREFIX.
|
||||||
*/
|
*/
|
||||||
# ifndef PNG_PREFIX
|
# ifndef PNG_PREFIX
|
||||||
@ -2889,12 +2924,19 @@ typedef struct
|
|||||||
* is the minimum 'row stride', the minimum count of components between each
|
* is the minimum 'row stride', the minimum count of components between each
|
||||||
* row. For a color-mapped image this is the minimum number of bytes in a
|
* row. For a color-mapped image this is the minimum number of bytes in a
|
||||||
* row.
|
* row.
|
||||||
|
*
|
||||||
|
* WARNING: this macro overflows for some images with more than one component
|
||||||
|
* and very large image widths. libpng will refuse to process an image where
|
||||||
|
* this macro would overflow.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
|
#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
|
||||||
(PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
|
(PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
|
||||||
/* Return the size, in bytes, of an image buffer given a png_image and a row
|
/* Return the size, in bytes, of an image buffer given a png_image and a row
|
||||||
* stride - the number of components to leave space for in each row.
|
* stride - the number of components to leave space for in each row.
|
||||||
|
*
|
||||||
|
* WARNING: this macro overflows a 32-bit integer for some large PNG images,
|
||||||
|
* libpng will refuse to process an image where such an overflow would occur.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_IMAGE_SIZE(image)\
|
#define PNG_IMAGE_SIZE(image)\
|
||||||
@ -3015,7 +3057,6 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
|
|||||||
#endif /* SIMPLIFIED_READ */
|
#endif /* SIMPLIFIED_READ */
|
||||||
|
|
||||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
|
||||||
/* WRITE APIS
|
/* WRITE APIS
|
||||||
* ----------
|
* ----------
|
||||||
* For write you must initialize a png_image structure to describe the image to
|
* For write you must initialize a png_image structure to describe the image to
|
||||||
@ -3032,6 +3073,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
|
|||||||
* values do not correspond to the colors in sRGB.
|
* values do not correspond to the colors in sRGB.
|
||||||
* colormap_entries: set to the number of entries in the color-map (0 to 256)
|
* colormap_entries: set to the number of entries in the color-map (0 to 256)
|
||||||
*/
|
*/
|
||||||
|
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
|
PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
|
||||||
const char *file, int convert_to_8bit, const void *buffer,
|
const char *file, int convert_to_8bit, const void *buffer,
|
||||||
png_int_32 row_stride, const void *colormap));
|
png_int_32 row_stride, const void *colormap));
|
||||||
@ -3041,8 +3083,9 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
|||||||
int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
|
int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
|
||||||
const void *colormap));
|
const void *colormap));
|
||||||
/* Write the image to the given (FILE*). */
|
/* Write the image to the given (FILE*). */
|
||||||
|
#endif /* SIMPLIFIED_WRITE_STDIO */
|
||||||
|
|
||||||
/* With both write APIs if image is in one of the linear formats with 16-bit
|
/* With all write APIs if image is in one of the linear formats with 16-bit
|
||||||
* data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
|
* data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
|
||||||
* gamma encoded according to the sRGB specification, otherwise a 16-bit linear
|
* gamma encoded according to the sRGB specification, otherwise a 16-bit linear
|
||||||
* encoded PNG file is written.
|
* encoded PNG file is written.
|
||||||
@ -3054,13 +3097,103 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
|||||||
*
|
*
|
||||||
* With all APIs row_stride is handled as in the read APIs - it is the spacing
|
* With all APIs row_stride is handled as in the read APIs - it is the spacing
|
||||||
* from one row to the next in component sized units (1 or 2 bytes) and if
|
* from one row to the next in component sized units (1 or 2 bytes) and if
|
||||||
* negative indicates a bottom-up row layout in the buffer. If row_stride is zero,
|
* negative indicates a bottom-up row layout in the buffer. If row_stride is
|
||||||
* libpng will calculate it for you from the image width and number of channels.
|
* zero, libpng will calculate it for you from the image width and number of
|
||||||
|
* channels.
|
||||||
*
|
*
|
||||||
* Note that the write API does not support interlacing, sub-8-bit pixels, indexed
|
* Note that the write API does not support interlacing, sub-8-bit pixels or
|
||||||
* PNG (color_type 3) or most ancillary chunks.
|
* most ancillary chunks. If you need to write text chunks (e.g. for copyright
|
||||||
|
* notices) you need to use one of the other APIs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
|
||||||
|
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit,
|
||||||
|
const void *buffer, png_int_32 row_stride, const void *colormap));
|
||||||
|
/* Write the image to the given memory buffer. The function both writes the
|
||||||
|
* whole PNG data stream to *memory and updates *memory_bytes with the count
|
||||||
|
* of bytes written.
|
||||||
|
*
|
||||||
|
* 'memory' may be NULL. In this case *memory_bytes is not read however on
|
||||||
|
* success the number of bytes which would have been written will still be
|
||||||
|
* stored in *memory_bytes. On failure *memory_bytes will contain 0.
|
||||||
|
*
|
||||||
|
* If 'memory' is not NULL it must point to memory[*memory_bytes] of
|
||||||
|
* writeable memory.
|
||||||
|
*
|
||||||
|
* If the function returns success memory[*memory_bytes] (if 'memory' is not
|
||||||
|
* NULL) contains the written PNG data. *memory_bytes will always be less
|
||||||
|
* than or equal to the original value.
|
||||||
|
*
|
||||||
|
* If the function returns false and *memory_bytes was not changed an error
|
||||||
|
* occured during write. If *memory_bytes was changed, or is not 0 if
|
||||||
|
* 'memory' was NULL, the write would have succeeded but for the memory
|
||||||
|
* buffer being too small. *memory_bytes contains the required number of
|
||||||
|
* bytes and will be bigger that the original value.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\
|
||||||
|
row_stride, colormap)\
|
||||||
|
png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
|
||||||
|
row_stride, colormap)
|
||||||
|
/* Return the amount of memory in 'size' required to compress this image.
|
||||||
|
* The png_image structure 'image' must be filled in as in the above
|
||||||
|
* function and must not be changed before the actual write call, the buffer
|
||||||
|
* and all other parameters must also be identical to that in the final
|
||||||
|
* write call. The 'size' variable need not be initialized.
|
||||||
|
*
|
||||||
|
* NOTE: the macro returns true/false, if false is returned 'size' will be
|
||||||
|
* set to zero and the write failed and probably will fail if tried again.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* You can pre-allocate the buffer by making sure it is of sufficient size
|
||||||
|
* regardless of the amount of compression achieved. The buffer size will
|
||||||
|
* always be bigger than the original image and it will never be filled. The
|
||||||
|
* following macros are provided to assist in allocating the buffer.
|
||||||
|
*/
|
||||||
|
#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height)
|
||||||
|
/* The number of uncompressed bytes in the PNG byte encoding of the image;
|
||||||
|
* uncompressing the PNG IDAT data will give this number of bytes.
|
||||||
|
*
|
||||||
|
* NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this
|
||||||
|
* macro can because of the extra bytes used in the PNG byte encoding. You
|
||||||
|
* need to avoid this macro if your image size approaches 2^30 in width or
|
||||||
|
* height. The same goes for the remainder of these macros; they all produce
|
||||||
|
* bigger numbers than the actual in-memory image size.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_ZLIB_MAX_SIZE
|
||||||
|
# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
|
||||||
|
/* An upper bound on the number of compressed bytes given 'b' uncompressed
|
||||||
|
* bytes. This is based on deflateBounds() in zlib; different
|
||||||
|
* implementations of zlib compression may conceivably produce more data so
|
||||||
|
* if your zlib implementation is not zlib itself redefine this macro
|
||||||
|
* appropriately.
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\
|
||||||
|
PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
|
||||||
|
/* An upper bound on the size of the data in the PNG IDAT chunks. */
|
||||||
|
|
||||||
|
#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
|
||||||
|
((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
|
||||||
|
(((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
|
||||||
|
12U+3U*(image).colormap_entries/*PLTE data*/+\
|
||||||
|
(((image).format&PNG_FORMAT_FLAG_ALPHA)?\
|
||||||
|
12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
|
||||||
|
12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
|
||||||
|
/* A helper for the following macro; if your compiler cannot handle the
|
||||||
|
* following macro use this one with the result of
|
||||||
|
* PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
|
||||||
|
* compilers should handle this just fine.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PNG_IMAGE_PNG_SIZE_MAX(image)\
|
||||||
|
PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
|
||||||
|
/* An upper bound on the total length of the PNG data stream for 'image'.
|
||||||
|
* The result is of type png_alloc_size_t, on 32-bit systems this may
|
||||||
|
* overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
|
||||||
|
* run out of buffer space but return a corrected size which should work.
|
||||||
*/
|
*/
|
||||||
#endif /* STDIO */
|
|
||||||
#endif /* SIMPLIFIED_WRITE */
|
#endif /* SIMPLIFIED_WRITE */
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* END OF SIMPLIFIED API
|
* END OF SIMPLIFIED API
|
||||||
@ -3094,7 +3227,10 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
|||||||
#endif
|
#endif
|
||||||
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
||||||
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
|
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
|
||||||
#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */
|
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||||
|
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
|
||||||
|
#endif
|
||||||
|
#define PNG_OPTION_NEXT 8 /* Next option - numbers must be even */
|
||||||
|
|
||||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||||
@ -3118,7 +3254,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
|||||||
* one to use is one more than this.)
|
* one to use is one more than this.)
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||||
PNG_EXPORT_LAST_ORDINAL(244);
|
PNG_EXPORT_LAST_ORDINAL(245);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
4
thirdparty/libpng/pngconf.h
vendored
4
thirdparty/libpng/pngconf.h
vendored
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.6.21, January 15, 2016
|
* libpng version 1.6.25, September 1, 2016
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
6
thirdparty/libpng/pngerror.c
vendored
6
thirdparty/libpng/pngerror.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -44,7 +44,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
|||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
if ((png_ptr->flags &
|
if ((png_ptr->flags &
|
||||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||||
{
|
{
|
||||||
if (*error_message == PNG_LITERAL_SHARP)
|
if (*error_message == PNG_LITERAL_SHARP)
|
||||||
{
|
{
|
||||||
|
4
thirdparty/libpng/pngget.c
vendored
4
thirdparty/libpng/pngget.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
5
thirdparty/libpng/pnglibconf.h
vendored
5
thirdparty/libpng/pnglibconf.h
vendored
@ -1,8 +1,8 @@
|
|||||||
/* libpng 1.6.21 STANDARD API DEFINITION */
|
/* libpng 1.6.25 STANDARD API DEFINITION */
|
||||||
|
|
||||||
/* pnglibconf.h - library build configuration */
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
/* Libpng version 1.6.21 - January 15, 2016 */
|
/* Libpng version 1.6.25 - September 1, 2016 */
|
||||||
|
|
||||||
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
@ -109,6 +109,7 @@
|
|||||||
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||||
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
#define PNG_STDIO_SUPPORTED
|
#define PNG_STDIO_SUPPORTED
|
||||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
4
thirdparty/libpng/pngmem.c
vendored
4
thirdparty/libpng/pngmem.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
* Last changed in libpng 1.6.24 [August 4, 2016%]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
13
thirdparty/libpng/pngpread.c
vendored
13
thirdparty/libpng/pngpread.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -77,7 +77,7 @@ png_process_data_pause(png_structrp png_ptr, int save)
|
|||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_process_data_skip(png_structrp png_ptr)
|
png_process_data_skip(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* TODO: Deprecate and remove this API.
|
/* TODO: Deprecate and remove this API.
|
||||||
* Somewhere the implementation of this seems to have been lost,
|
* Somewhere the implementation of this seems to have been lost,
|
||||||
* or abandoned. It was only to support some internal back-door access
|
* or abandoned. It was only to support some internal back-door access
|
||||||
* to png_struct) in libpng-1.4.x.
|
* to png_struct) in libpng-1.4.x.
|
||||||
@ -210,13 +210,15 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
|
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
|
||||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||||
|
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
|
||||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||||
|
|
||||||
|
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
|
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
|
||||||
if (png_ptr->push_length == 0)
|
if (png_ptr->push_length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||||
|
|
||||||
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||||
png_benign_error(png_ptr, "Too many IDATs found");
|
png_benign_error(png_ptr, "Too many IDATs found");
|
||||||
}
|
}
|
||||||
@ -499,7 +501,10 @@ png_push_save_buffer(png_structrp png_ptr)
|
|||||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (old_buffer)
|
||||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||||
|
else if (png_ptr->save_buffer_size)
|
||||||
|
png_error(png_ptr, "save_buffer error");
|
||||||
png_free(png_ptr, old_buffer);
|
png_free(png_ptr, old_buffer);
|
||||||
png_ptr->save_buffer_max = new_max;
|
png_ptr->save_buffer_max = new_max;
|
||||||
}
|
}
|
||||||
|
61
thirdparty/libpng/pngpriv.h
vendored
61
thirdparty/libpng/pngpriv.h
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngpriv.h - private declarations for use inside libpng
|
/* pngpriv.h - private declarations for use inside libpng
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.21 [January 15, 2016]
|
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -182,6 +182,35 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
|
|
||||||
|
#ifndef PNG_MIPS_MSA_OPT
|
||||||
|
# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||||
|
# define PNG_MIPS_MSA_OPT 2
|
||||||
|
# else
|
||||||
|
# define PNG_MIPS_MSA_OPT 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
|
||||||
|
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
|
||||||
|
# if defined(__mips_msa)
|
||||||
|
# if defined(__clang__)
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
|
||||||
|
# define PNG_MIPS_MSA_IMPLEMENTATION 2
|
||||||
|
# endif /* no GNUC support */
|
||||||
|
# endif /* __GNUC__ */
|
||||||
|
# else /* !defined __mips_msa */
|
||||||
|
# define PNG_MIPS_MSA_IMPLEMENTATION 2
|
||||||
|
# endif /* __mips_msa */
|
||||||
|
# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */
|
||||||
|
|
||||||
|
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
|
||||||
|
# define PNG_MIPS_MSA_IMPLEMENTATION 1
|
||||||
|
# endif
|
||||||
|
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||||
|
|
||||||
|
|
||||||
/* Is this a build of a DLL where compilation of the object modules requires
|
/* Is this a build of a DLL where compilation of the object modules requires
|
||||||
* different preprocessor settings to those required for a simple library? If
|
* different preprocessor settings to those required for a simple library? If
|
||||||
* so PNG_BUILD_DLL must be set.
|
* so PNG_BUILD_DLL must be set.
|
||||||
@ -1174,6 +1203,7 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,
|
|||||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
|
||||||
row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
|
row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
|
||||||
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
|
||||||
@ -1188,6 +1218,24 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop
|
|||||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
|
||||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
|
||||||
|
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
|
||||||
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop
|
||||||
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop
|
||||||
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop
|
||||||
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop
|
||||||
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
|
||||||
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Choose the best filter to use and filter the row data */
|
/* Choose the best filter to use and filter the row data */
|
||||||
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
|
||||||
@ -1492,9 +1540,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
|
|||||||
/* The 'name' is used for information only */
|
/* The 'name' is used for information only */
|
||||||
|
|
||||||
/* Routines for checking parts of an ICC profile. */
|
/* Routines for checking parts of an ICC profile. */
|
||||||
|
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
|
||||||
png_colorspacerp colorspace, png_const_charp name,
|
png_colorspacerp colorspace, png_const_charp name,
|
||||||
png_uint_32 profile_length), PNG_EMPTY);
|
png_uint_32 profile_length), PNG_EMPTY);
|
||||||
|
#endif /* READ_iCCP */
|
||||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
|
||||||
png_colorspacerp colorspace, png_const_charp name,
|
png_colorspacerp colorspace, png_const_charp name,
|
||||||
png_uint_32 profile_length,
|
png_uint_32 profile_length,
|
||||||
@ -1913,10 +1963,17 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
|
|||||||
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
|
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
|
||||||
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
|
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
|
||||||
*/
|
*/
|
||||||
|
# if PNG_ARM_NEON_OPT > 0
|
||||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
||||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
|
||||||
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
||||||
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
||||||
|
|
||||||
|
126
thirdparty/libpng/pngread.c
vendored
126
thirdparty/libpng/pngread.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -127,7 +127,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||||
|
{
|
||||||
|
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||||
|
}
|
||||||
|
|
||||||
/* This should be a binary subdivision search or a hash for
|
/* This should be a binary subdivision search or a hash for
|
||||||
* matching the chunk name rather than a linear search.
|
* matching the chunk name rather than a linear search.
|
||||||
@ -785,6 +788,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
png_uint_32 length = png_read_chunk_header(png_ptr);
|
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||||
|
|
||||||
|
if (chunk_name != png_IDAT)
|
||||||
|
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||||
|
|
||||||
if (chunk_name == png_IEND)
|
if (chunk_name == png_IEND)
|
||||||
png_handle_IEND(png_ptr, info_ptr, length);
|
png_handle_IEND(png_ptr, info_ptr, length);
|
||||||
|
|
||||||
@ -799,9 +805,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
{
|
{
|
||||||
if (chunk_name == png_IDAT)
|
if (chunk_name == png_IDAT)
|
||||||
{
|
{
|
||||||
if ((length > 0) ||
|
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||||
png_benign_error(png_ptr, "Too many IDATs found");
|
png_benign_error(png_ptr, ".Too many IDATs found");
|
||||||
}
|
}
|
||||||
png_handle_unknown(png_ptr, info_ptr, length, keep);
|
png_handle_unknown(png_ptr, info_ptr, length, keep);
|
||||||
if (chunk_name == png_PLTE)
|
if (chunk_name == png_PLTE)
|
||||||
@ -812,10 +818,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
else if (chunk_name == png_IDAT)
|
else if (chunk_name == png_IDAT)
|
||||||
{
|
{
|
||||||
/* Zero length IDATs are legal after the last IDAT has been
|
/* Zero length IDATs are legal after the last IDAT has been
|
||||||
* read, but not after other chunks have been read.
|
* read, but not after other chunks have been read. 1.6 does not
|
||||||
|
* always read all the deflate data; specifically it cannot be relied
|
||||||
|
* upon to read the Adler32 at the end. If it doesn't ignore IDAT
|
||||||
|
* chunks which are longer than zero as well:
|
||||||
*/
|
*/
|
||||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||||
png_benign_error(png_ptr, "Too many IDATs found");
|
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||||
|
png_benign_error(png_ptr, "..Too many IDATs found");
|
||||||
|
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
}
|
}
|
||||||
@ -1020,8 +1030,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
|
|||||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
int transforms,
|
int transforms, voidp params)
|
||||||
voidp params)
|
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
@ -2095,7 +2104,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
|
|
||||||
else if (display->background == NULL /* no way to remove it */)
|
else if (display->background == NULL /* no way to remove it */)
|
||||||
png_error(png_ptr,
|
png_error(png_ptr,
|
||||||
"a background color must be supplied to remove alpha/transparency");
|
"background color must be supplied to remove alpha/transparency");
|
||||||
|
|
||||||
/* Get a copy of the background color (this avoids repeating the checks
|
/* Get a copy of the background color (this avoids repeating the checks
|
||||||
* below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
|
* below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
|
||||||
@ -2420,8 +2429,8 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
background_index = i;
|
background_index = i;
|
||||||
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
|
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
|
||||||
#ifdef __COVERITY__
|
#ifdef __COVERITY__
|
||||||
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
|
/* Coverity claims that output_encoding
|
||||||
* here.
|
* cannot be 2 (P_LINEAR) here.
|
||||||
*/ 255U,
|
*/ 255U,
|
||||||
#else
|
#else
|
||||||
output_encoding == P_LINEAR ? 65535U : 255U,
|
output_encoding == P_LINEAR ? 65535U : 255U,
|
||||||
@ -2809,12 +2818,12 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
* on the sRGB color in 'back'.
|
* on the sRGB color in 'back'.
|
||||||
*/
|
*/
|
||||||
png_create_colormap_entry(display, i,
|
png_create_colormap_entry(display, i,
|
||||||
png_colormap_compose(display, colormap[i].red, P_FILE,
|
png_colormap_compose(display, colormap[i].red,
|
||||||
trans[i], back_r, output_encoding),
|
P_FILE, trans[i], back_r, output_encoding),
|
||||||
png_colormap_compose(display, colormap[i].green, P_FILE,
|
png_colormap_compose(display, colormap[i].green,
|
||||||
trans[i], back_g, output_encoding),
|
P_FILE, trans[i], back_g, output_encoding),
|
||||||
png_colormap_compose(display, colormap[i].blue, P_FILE,
|
png_colormap_compose(display, colormap[i].blue,
|
||||||
trans[i], back_b, output_encoding),
|
P_FILE, trans[i], back_b, output_encoding),
|
||||||
output_encoding == P_LINEAR ? trans[i] * 257U :
|
output_encoding == P_LINEAR ? trans[i] * 257U :
|
||||||
trans[i],
|
trans[i],
|
||||||
output_encoding);
|
output_encoding);
|
||||||
@ -3423,8 +3432,7 @@ png_image_read_background(png_voidp argument)
|
|||||||
|
|
||||||
for (pass = 0; pass < passes; ++pass)
|
for (pass = 0; pass < passes; ++pass)
|
||||||
{
|
{
|
||||||
png_bytep row = png_voidcast(png_bytep,
|
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||||
display->first_row);
|
|
||||||
unsigned int startx, stepx, stepy;
|
unsigned int startx, stepx, stepy;
|
||||||
png_uint_32 y;
|
png_uint_32 y;
|
||||||
|
|
||||||
@ -3848,7 +3856,7 @@ png_image_read_direct(png_voidp argument)
|
|||||||
else
|
else
|
||||||
filler = 255;
|
filler = 255;
|
||||||
|
|
||||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||||
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||||
{
|
{
|
||||||
where = PNG_FILLER_BEFORE;
|
where = PNG_FILLER_BEFORE;
|
||||||
@ -3856,7 +3864,7 @@ png_image_read_direct(png_voidp argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
# endif
|
#endif
|
||||||
where = PNG_FILLER_AFTER;
|
where = PNG_FILLER_AFTER;
|
||||||
|
|
||||||
png_set_add_alpha(png_ptr, filler, where);
|
png_set_add_alpha(png_ptr, filler, where);
|
||||||
@ -3965,12 +3973,12 @@ png_image_read_direct(png_voidp argument)
|
|||||||
if (info_ptr->bit_depth == 16)
|
if (info_ptr->bit_depth == 16)
|
||||||
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
||||||
|
|
||||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||||
info_format |= PNG_FORMAT_FLAG_BGR;
|
info_format |= PNG_FORMAT_FLAG_BGR;
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||||
if (do_local_background == 2)
|
if (do_local_background == 2)
|
||||||
{
|
{
|
||||||
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||||
@ -4070,11 +4078,26 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
void *buffer, png_int_32 row_stride, void *colormap)
|
void *buffer, png_int_32 row_stride, void *colormap)
|
||||||
{
|
{
|
||||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||||
|
{
|
||||||
|
/* Check for row_stride overflow. This check is not performed on the
|
||||||
|
* original PNG format because it may not occur in the output PNG format
|
||||||
|
* and libpng deals with the issues of reading the original.
|
||||||
|
*/
|
||||||
|
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||||
|
|
||||||
|
/* The following checks just the 'row_stride' calculation to ensure it
|
||||||
|
* fits in a signed 32-bit value. Because channels/components can be
|
||||||
|
* either 1 or 2 bytes in size the length of a row can still overflow 32
|
||||||
|
* bits; this is just to verify that the 'row_stride' argument can be
|
||||||
|
* represented.
|
||||||
|
*/
|
||||||
|
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
|
||||||
{
|
{
|
||||||
png_uint_32 check;
|
png_uint_32 check;
|
||||||
|
const png_uint_32 png_row_stride = image->width * channels;
|
||||||
|
|
||||||
if (row_stride == 0)
|
if (row_stride == 0)
|
||||||
row_stride = PNG_IMAGE_ROW_STRIDE(*image);
|
row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||||
|
|
||||||
if (row_stride < 0)
|
if (row_stride < 0)
|
||||||
check = -row_stride;
|
check = -row_stride;
|
||||||
@ -4082,8 +4105,30 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
else
|
else
|
||||||
check = row_stride;
|
check = row_stride;
|
||||||
|
|
||||||
if (image->opaque != NULL && buffer != NULL &&
|
/* This verifies 'check', the absolute value of the actual stride
|
||||||
check >= PNG_IMAGE_ROW_STRIDE(*image))
|
* passed in and detects overflow in the application calculation (i.e.
|
||||||
|
* if the app did actually pass in a non-zero 'row_stride'.
|
||||||
|
*/
|
||||||
|
if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
|
||||||
|
{
|
||||||
|
/* Now check for overflow of the image buffer calculation; this
|
||||||
|
* limits the whole image size to 32 bits for API compatibility with
|
||||||
|
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
|
||||||
|
*
|
||||||
|
* The PNG_IMAGE_BUFFER_SIZE macro is:
|
||||||
|
*
|
||||||
|
* (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride))
|
||||||
|
*
|
||||||
|
* And the component size is always 1 or 2, so make sure that the
|
||||||
|
* number of *bytes* that the application is saying are available
|
||||||
|
* does actually fit into a 32-bit number.
|
||||||
|
*
|
||||||
|
* NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE
|
||||||
|
* will be changed to use png_alloc_size_t; bigger images can be
|
||||||
|
* accomodated on 64-bit systems.
|
||||||
|
*/
|
||||||
|
if (image->height <=
|
||||||
|
0xFFFFFFFFU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
|
||||||
{
|
{
|
||||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
|
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
|
||||||
(image->colormap_entries > 0 && colormap != NULL))
|
(image->colormap_entries > 0 && colormap != NULL))
|
||||||
@ -4099,17 +4144,20 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
display.background = background;
|
display.background = background;
|
||||||
display.local_row = NULL;
|
display.local_row = NULL;
|
||||||
|
|
||||||
/* Choose the correct 'end' routine; for the color-map case all the
|
/* Choose the correct 'end' routine; for the color-map case
|
||||||
* setup has already been done.
|
* all the setup has already been done.
|
||||||
*/
|
*/
|
||||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||||
result =
|
result =
|
||||||
png_safe_execute(image, png_image_read_colormap, &display) &&
|
png_safe_execute(image,
|
||||||
png_safe_execute(image, png_image_read_colormapped, &display);
|
png_image_read_colormap, &display) &&
|
||||||
|
png_safe_execute(image,
|
||||||
|
png_image_read_colormapped, &display);
|
||||||
|
|
||||||
else
|
else
|
||||||
result =
|
result =
|
||||||
png_safe_execute(image, png_image_read_direct, &display);
|
png_safe_execute(image,
|
||||||
|
png_image_read_direct, &display);
|
||||||
|
|
||||||
png_image_free(image);
|
png_image_free(image);
|
||||||
return result;
|
return result;
|
||||||
@ -4120,11 +4168,21 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
"png_image_finish_read[color-map]: no color-map");
|
"png_image_finish_read[color-map]: no color-map");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return png_image_error(image,
|
||||||
|
"png_image_finish_read: image too large");
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
return png_image_error(image,
|
return png_image_error(image,
|
||||||
"png_image_finish_read: invalid argument");
|
"png_image_finish_read: invalid argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return png_image_error(image,
|
||||||
|
"png_image_finish_read: row_stride too large");
|
||||||
|
}
|
||||||
|
|
||||||
else if (image != NULL)
|
else if (image != NULL)
|
||||||
return png_image_error(image,
|
return png_image_error(image,
|
||||||
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
|
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
|
||||||
|
4
thirdparty/libpng/pngrio.c
vendored
4
thirdparty/libpng/pngrio.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
11
thirdparty/libpng/pngrtran.c
vendored
11
thirdparty/libpng/pngrtran.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -289,9 +289,12 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
|||||||
* is expected to be 1 or greater, but this range test allows for some
|
* is expected to be 1 or greater, but this range test allows for some
|
||||||
* viewing correction values. The intent is to weed out users of this API
|
* viewing correction values. The intent is to weed out users of this API
|
||||||
* who use the inverse of the gamma value accidentally! Since some of these
|
* who use the inverse of the gamma value accidentally! Since some of these
|
||||||
* values are reasonable this may have to be changed.
|
* values are reasonable this may have to be changed:
|
||||||
|
*
|
||||||
|
* 1.6.x: changed from 0.07..3 to 0.01..100 (to accomodate the optimal 16-bit
|
||||||
|
* gamma of 36, and its reciprocal.)
|
||||||
*/
|
*/
|
||||||
if (output_gamma < 70000 || output_gamma > 300000)
|
if (output_gamma < 1000 || output_gamma > 10000000)
|
||||||
png_error(png_ptr, "output gamma out of expected range");
|
png_error(png_ptr, "output gamma out of expected range");
|
||||||
|
|
||||||
/* The default file gamma is the inverse of the output gamma; the output
|
/* The default file gamma is the inverse of the output gamma; the output
|
||||||
|
16
thirdparty/libpng/pngrutil.c
vendored
16
thirdparty/libpng/pngrutil.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.20 [December 3, 2014]
|
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -461,6 +461,7 @@ png_zlib_inflate(png_structrp png_ptr, int flush)
|
|||||||
#endif /* Zlib >= 1.2.4 */
|
#endif /* Zlib >= 1.2.4 */
|
||||||
|
|
||||||
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||||
|
#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED)
|
||||||
/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
|
/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
|
||||||
* allow the caller to do multiple calls if required. If the 'finish' flag is
|
* allow the caller to do multiple calls if required. If the 'finish' flag is
|
||||||
* set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must
|
* set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must
|
||||||
@ -754,6 +755,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* READ_zTXt || READ_iTXt */
|
||||||
#endif /* READ_COMPRESSED_TEXT */
|
#endif /* READ_COMPRESSED_TEXT */
|
||||||
|
|
||||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||||
@ -802,8 +804,8 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
|||||||
* the available output is produced; this allows reading of truncated
|
* the available output is produced; this allows reading of truncated
|
||||||
* streams.
|
* streams.
|
||||||
*/
|
*/
|
||||||
ret = PNG_INFLATE(png_ptr,
|
ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ?
|
||||||
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
|
Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||||
}
|
}
|
||||||
while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
|
while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
|
||||||
|
|
||||||
@ -1512,7 +1514,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
finished = 1;
|
finished = 1;
|
||||||
|
|
||||||
# ifdef PNG_sRGB_SUPPORTED
|
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||||
/* Check for a match against sRGB */
|
/* Check for a match against sRGB */
|
||||||
png_icc_set_sRGB(png_ptr,
|
png_icc_set_sRGB(png_ptr,
|
||||||
&png_ptr->colorspace, profile,
|
&png_ptr->colorspace, profile,
|
||||||
@ -3418,8 +3420,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
|||||||
/* Everything is aligned for png_uint_16 copies, but try for
|
/* Everything is aligned for png_uint_16 copies, but try for
|
||||||
* png_uint_32 first.
|
* png_uint_32 first.
|
||||||
*/
|
*/
|
||||||
if (png_isaligned(dp, png_uint_32) != 0 &&
|
if (png_isaligned(dp, png_uint_32) &&
|
||||||
png_isaligned(sp, png_uint_32) != 0 &&
|
png_isaligned(sp, png_uint_32) &&
|
||||||
bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
|
bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
|
||||||
bytes_to_jump % (sizeof (png_uint_32)) == 0)
|
bytes_to_jump % (sizeof (png_uint_32)) == 0)
|
||||||
{
|
{
|
||||||
|
20
thirdparty/libpng/pngset.c
vendored
20
thirdparty/libpng/pngset.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.21 [January 15, 2016]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -952,13 +952,15 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
|
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||||
|
|
||||||
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
|
||||||
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
|
|
||||||
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
|
||||||
|
|
||||||
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||||
|
{
|
||||||
|
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
||||||
|
info_ptr->trans_alpha = png_voidcast(png_bytep,
|
||||||
|
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
||||||
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
|
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
|
||||||
}
|
}
|
||||||
|
png_ptr->trans_alpha = info_ptr->trans_alpha;
|
||||||
|
}
|
||||||
|
|
||||||
if (trans_color != NULL)
|
if (trans_color != NULL)
|
||||||
{
|
{
|
||||||
@ -1660,7 +1662,9 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
|||||||
png_uint_32 /* PRIVATE */
|
png_uint_32 /* PRIVATE */
|
||||||
png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
png_const_charp orig_key = key;
|
png_const_charp orig_key = key;
|
||||||
|
#endif
|
||||||
png_uint_32 key_len = 0;
|
png_uint_32 key_len = 0;
|
||||||
int bad_character = 0;
|
int bad_character = 0;
|
||||||
int space = 1;
|
int space = 1;
|
||||||
@ -1723,7 +1727,9 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||||||
|
|
||||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||||
}
|
}
|
||||||
#endif /* WARNINGS */
|
#else /* !WARNINGS */
|
||||||
|
PNG_UNUSED(png_ptr)
|
||||||
|
#endif /* !WARNINGS */
|
||||||
|
|
||||||
return key_len;
|
return key_len;
|
||||||
}
|
}
|
||||||
|
6
thirdparty/libpng/pngstruct.h
vendored
6
thirdparty/libpng/pngstruct.h
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngstruct.h - header file for PNG reference library
|
/* pngstruct.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -249,7 +249,7 @@ struct png_struct_def
|
|||||||
png_byte filter; /* file filter type (always 0) */
|
png_byte filter; /* file filter type (always 0) */
|
||||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||||
png_byte pass; /* current interlace pass (0 - 6) */
|
png_byte pass; /* current interlace pass (0 - 6) */
|
||||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */
|
||||||
png_byte color_type; /* color type of file */
|
png_byte color_type; /* color type of file */
|
||||||
png_byte bit_depth; /* bit depth of file */
|
png_byte bit_depth; /* bit depth of file */
|
||||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||||
|
7
thirdparty/libpng/pngtrans.c
vendored
7
thirdparty/libpng/pngtrans.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -172,7 +172,8 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
|||||||
* size!
|
* size!
|
||||||
*/
|
*/
|
||||||
png_app_error(png_ptr,
|
png_app_error(png_ptr,
|
||||||
"png_set_filler is invalid for low bit depth gray output");
|
"png_set_filler is invalid for"
|
||||||
|
" low bit depth gray output");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
thirdparty/libpng/pngwio.c
vendored
4
thirdparty/libpng/pngwio.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
173
thirdparty/libpng/pngwrite.c
vendored
173
thirdparty/libpng/pngwrite.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -12,9 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pngpriv.h"
|
#include "pngpriv.h"
|
||||||
#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
|
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
#endif
|
#endif /* SIMPLIFIED_WRITE_STDIO */
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
|
||||||
@ -1452,7 +1452,6 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
|
|
||||||
|
|
||||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
# ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
|
|
||||||
/* Initialize the write structure - general purpose utility. */
|
/* Initialize the write structure - general purpose utility. */
|
||||||
static int
|
static int
|
||||||
png_image_write_init(png_imagep image)
|
png_image_write_init(png_imagep image)
|
||||||
@ -1504,6 +1503,10 @@ typedef struct
|
|||||||
png_const_voidp first_row;
|
png_const_voidp first_row;
|
||||||
ptrdiff_t row_bytes;
|
ptrdiff_t row_bytes;
|
||||||
png_voidp local_row;
|
png_voidp local_row;
|
||||||
|
/* Byte count for memory writing */
|
||||||
|
png_bytep memory;
|
||||||
|
png_alloc_size_t memory_bytes; /* not used for STDIO */
|
||||||
|
png_alloc_size_t output_bytes; /* running total */
|
||||||
} png_image_write_control;
|
} png_image_write_control;
|
||||||
|
|
||||||
/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to
|
/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to
|
||||||
@ -1931,9 +1934,43 @@ png_image_write_main(png_voidp argument)
|
|||||||
png_set_benign_errors(png_ptr, 0/*error*/);
|
png_set_benign_errors(png_ptr, 0/*error*/);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Default the 'row_stride' parameter if required. */
|
/* Default the 'row_stride' parameter if required, also check the row stride
|
||||||
|
* and total image size to ensure that they are within the system limits.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||||
|
|
||||||
|
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
|
||||||
|
{
|
||||||
|
png_uint_32 check;
|
||||||
|
const png_uint_32 png_row_stride = image->width * channels;
|
||||||
|
|
||||||
if (display->row_stride == 0)
|
if (display->row_stride == 0)
|
||||||
display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
|
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||||
|
|
||||||
|
if (display->row_stride < 0)
|
||||||
|
check = -display->row_stride;
|
||||||
|
|
||||||
|
else
|
||||||
|
check = display->row_stride;
|
||||||
|
|
||||||
|
if (check >= png_row_stride)
|
||||||
|
{
|
||||||
|
/* Now check for overflow of the image buffer calculation; this
|
||||||
|
* limits the whole image size to 32 bits for API compatibility with
|
||||||
|
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
|
||||||
|
*/
|
||||||
|
if (image->height > 0xFFFFFFFF/png_row_stride)
|
||||||
|
png_error(image->opaque->png_ptr, "memory image too large");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(image->opaque->png_ptr, "supplied row stride too small");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(image->opaque->png_ptr, "image row stride too large");
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the required transforms then write the rows in the correct order. */
|
/* Set the required transforms then write the rows in the correct order. */
|
||||||
if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||||
@ -2110,6 +2147,122 @@ png_image_write_main(png_voidp argument)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void (PNGCBAPI
|
||||||
|
image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data,
|
||||||
|
png_size_t size)
|
||||||
|
{
|
||||||
|
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||||
|
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
|
||||||
|
const png_alloc_size_t ob = display->output_bytes;
|
||||||
|
|
||||||
|
/* Check for overflow; this should never happen: */
|
||||||
|
if (size <= ((png_alloc_size_t)-1) - ob)
|
||||||
|
{
|
||||||
|
/* I don't think libpng ever does this, but just in case: */
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
|
if (display->memory_bytes >= ob+size) /* writing */
|
||||||
|
memcpy(display->memory+ob, data, size);
|
||||||
|
|
||||||
|
/* Always update the size: */
|
||||||
|
display->output_bytes = ob+size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "png_image_write_to_memory: PNG too big");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void (PNGCBAPI
|
||||||
|
image_memory_flush)(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
PNG_UNUSED(png_ptr)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
png_image_write_memory(png_voidp argument)
|
||||||
|
{
|
||||||
|
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||||
|
argument);
|
||||||
|
|
||||||
|
/* The rest of the memory-specific init and write_main in an error protected
|
||||||
|
* environment. This case needs to use callbacks for the write operations
|
||||||
|
* since libpng has no built in support for writing to memory.
|
||||||
|
*/
|
||||||
|
png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
|
||||||
|
image_memory_write, image_memory_flush);
|
||||||
|
|
||||||
|
return png_image_write_main(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
int PNGAPI
|
||||||
|
png_image_write_to_memory(png_imagep image, void *memory,
|
||||||
|
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
|
||||||
|
const void *buffer, png_int_32 row_stride, const void *colormap)
|
||||||
|
{
|
||||||
|
/* Write the image to the given buffer, or count the bytes if it is NULL */
|
||||||
|
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||||
|
{
|
||||||
|
if (memory_bytes != NULL && buffer != NULL)
|
||||||
|
{
|
||||||
|
/* This is to give the caller an easier error detection in the NULL
|
||||||
|
* case and guard against uninitialized variable problems:
|
||||||
|
*/
|
||||||
|
if (memory == NULL)
|
||||||
|
*memory_bytes = 0;
|
||||||
|
|
||||||
|
if (png_image_write_init(image) != 0)
|
||||||
|
{
|
||||||
|
png_image_write_control display;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
memset(&display, 0, (sizeof display));
|
||||||
|
display.image = image;
|
||||||
|
display.buffer = buffer;
|
||||||
|
display.row_stride = row_stride;
|
||||||
|
display.colormap = colormap;
|
||||||
|
display.convert_to_8bit = convert_to_8bit;
|
||||||
|
display.memory = png_voidcast(png_bytep, memory);
|
||||||
|
display.memory_bytes = *memory_bytes;
|
||||||
|
display.output_bytes = 0;
|
||||||
|
|
||||||
|
result = png_safe_execute(image, png_image_write_memory, &display);
|
||||||
|
png_image_free(image);
|
||||||
|
|
||||||
|
/* write_memory returns true even if we ran out of buffer. */
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
/* On out-of-buffer this function returns '0' but still updates
|
||||||
|
* memory_bytes:
|
||||||
|
*/
|
||||||
|
if (memory != NULL && display.output_bytes > *memory_bytes)
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
*memory_bytes = display.output_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return png_image_error(image,
|
||||||
|
"png_image_write_to_memory: invalid argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (image != NULL)
|
||||||
|
return png_image_error(image,
|
||||||
|
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
|
||||||
|
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||||
const void *buffer, png_int_32 row_stride, const void *colormap)
|
const void *buffer, png_int_32 row_stride, const void *colormap)
|
||||||
@ -2117,7 +2270,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
|||||||
/* Write the image to the given (FILE*). */
|
/* Write the image to the given (FILE*). */
|
||||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||||
{
|
{
|
||||||
if (file != NULL)
|
if (file != NULL && buffer != NULL)
|
||||||
{
|
{
|
||||||
if (png_image_write_init(image) != 0)
|
if (png_image_write_init(image) != 0)
|
||||||
{
|
{
|
||||||
@ -2167,7 +2320,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
|||||||
/* Write the image to the named file. */
|
/* Write the image to the named file. */
|
||||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||||
{
|
{
|
||||||
if (file_name != NULL)
|
if (file_name != NULL && buffer != NULL)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(file_name, "wb");
|
FILE *fp = fopen(file_name, "wb");
|
||||||
|
|
||||||
@ -2225,6 +2378,6 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
# endif /* STDIO */
|
#endif /* SIMPLIFIED_WRITE_STDIO */
|
||||||
#endif /* SIMPLIFIED_WRITE */
|
#endif /* SIMPLIFIED_WRITE */
|
||||||
#endif /* WRITE */
|
#endif /* WRITE */
|
||||||
|
4
thirdparty/libpng/pngwtran.c
vendored
4
thirdparty/libpng/pngwtran.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
190
thirdparty/libpng/pngwutil.c
vendored
190
thirdparty/libpng/pngwutil.c
vendored
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngwutil.c - utilities to write a PNG file
|
/* pngwutil.c - utilities to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.21 [January 15, 2016]
|
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@ -23,10 +23,10 @@
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_save_uint_32(png_bytep buf, png_uint_32 i)
|
png_save_uint_32(png_bytep buf, png_uint_32 i)
|
||||||
{
|
{
|
||||||
buf[0] = (png_byte)(i >> 24);
|
buf[0] = (png_byte)((i >> 24) & 0xffU);
|
||||||
buf[1] = (png_byte)(i >> 16);
|
buf[1] = (png_byte)((i >> 16) & 0xffU);
|
||||||
buf[2] = (png_byte)(i >> 8);
|
buf[2] = (png_byte)((i >> 8) & 0xffU);
|
||||||
buf[3] = (png_byte)(i );
|
buf[3] = (png_byte)( i & 0xffU);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Place a 16-bit number into a buffer in PNG byte order.
|
/* Place a 16-bit number into a buffer in PNG byte order.
|
||||||
@ -36,8 +36,8 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_save_uint_16(png_bytep buf, unsigned int i)
|
png_save_uint_16(png_bytep buf, unsigned int i)
|
||||||
{
|
{
|
||||||
buf[0] = (png_byte)(i >> 8);
|
buf[0] = (png_byte)((i >> 8) & 0xffU);
|
||||||
buf[1] = (png_byte)(i );
|
buf[1] = (png_byte)( i & 0xffU);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1441,7 +1441,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
|
"Ignoring attempt to write 16-bit bKGD chunk "
|
||||||
|
"when bit_depth is 8");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2262,14 +2263,22 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
i++, rp++, dp++)
|
i++, rp++, dp++)
|
||||||
{
|
{
|
||||||
v = *dp = *rp;
|
v = *dp = *rp;
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
||||||
i++, rp++, lp++, dp++)
|
i++, rp++, lp++, dp++)
|
||||||
{
|
{
|
||||||
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2278,6 +2287,28 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void /* PRIVATE */
|
||||||
|
png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
|
const png_size_t row_bytes)
|
||||||
|
{
|
||||||
|
png_bytep rp, dp, lp;
|
||||||
|
png_size_t i;
|
||||||
|
|
||||||
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
|
||||||
|
|
||||||
|
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
|
||||||
|
i++, rp++, dp++)
|
||||||
|
{
|
||||||
|
*dp = *rp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
||||||
|
i++, rp++, lp++, dp++)
|
||||||
|
{
|
||||||
|
*dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static png_size_t /* PRIVATE */
|
static png_size_t /* PRIVATE */
|
||||||
png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
||||||
const png_size_t lmins)
|
const png_size_t lmins)
|
||||||
@ -2294,7 +2325,11 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||||||
i++, rp++, pp++, dp++)
|
i++, rp++, pp++, dp++)
|
||||||
{
|
{
|
||||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2302,6 +2337,21 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
|
static void /* PRIVATE */
|
||||||
|
png_setup_up_row_only(png_structrp png_ptr, const png_size_t row_bytes)
|
||||||
|
{
|
||||||
|
png_bytep rp, dp, pp;
|
||||||
|
png_size_t i;
|
||||||
|
|
||||||
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
|
||||||
|
|
||||||
|
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
||||||
|
pp = png_ptr->prev_row + 1; i < row_bytes;
|
||||||
|
i++, rp++, pp++, dp++)
|
||||||
|
{
|
||||||
|
*dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static png_size_t /* PRIVATE */
|
static png_size_t /* PRIVATE */
|
||||||
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
@ -2319,7 +2369,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
{
|
{
|
||||||
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
||||||
@ -2327,7 +2381,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||||
& 0xff);
|
& 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2335,6 +2393,27 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
|
static void /* PRIVATE */
|
||||||
|
png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
|
const png_size_t row_bytes)
|
||||||
|
{
|
||||||
|
png_bytep rp, dp, pp, lp;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
|
||||||
|
|
||||||
|
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
||||||
|
pp = png_ptr->prev_row + 1; i < bpp; i++)
|
||||||
|
{
|
||||||
|
*dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
||||||
|
{
|
||||||
|
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||||
|
& 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static png_size_t /* PRIVATE */
|
static png_size_t /* PRIVATE */
|
||||||
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
@ -2352,7 +2431,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
{
|
{
|
||||||
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
||||||
@ -2381,7 +2464,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
|
|
||||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sum > lmins) /* We are already worse, don't continue. */
|
if (sum > lmins) /* We are already worse, don't continue. */
|
||||||
break;
|
break;
|
||||||
@ -2389,6 +2476,48 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
|
|
||||||
return (sum);
|
return (sum);
|
||||||
}
|
}
|
||||||
|
static void /* PRIVATE */
|
||||||
|
png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||||
|
const png_size_t row_bytes)
|
||||||
|
{
|
||||||
|
png_bytep rp, dp, pp, cp, lp;
|
||||||
|
png_size_t i;
|
||||||
|
|
||||||
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||||
|
|
||||||
|
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
||||||
|
pp = png_ptr->prev_row + 1; i < bpp; i++)
|
||||||
|
{
|
||||||
|
*dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
||||||
|
i++)
|
||||||
|
{
|
||||||
|
int a, b, c, pa, pb, pc, p;
|
||||||
|
|
||||||
|
b = *pp++;
|
||||||
|
c = *cp++;
|
||||||
|
a = *lp++;
|
||||||
|
|
||||||
|
p = b - c;
|
||||||
|
pc = a - c;
|
||||||
|
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
pa = abs(p);
|
||||||
|
pb = abs(pc);
|
||||||
|
pc = abs(p + pc);
|
||||||
|
#else
|
||||||
|
pa = p < 0 ? -p : p;
|
||||||
|
pb = pc < 0 ? -pc : pc;
|
||||||
|
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||||
|
|
||||||
|
*dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /* WRITE_FILTER */
|
#endif /* WRITE_FILTER */
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
@ -2397,7 +2526,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
#ifndef PNG_WRITE_FILTER_SUPPORTED
|
#ifndef PNG_WRITE_FILTER_SUPPORTED
|
||||||
png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1);
|
png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1);
|
||||||
#else
|
#else
|
||||||
png_byte filter_to_do = png_ptr->do_filter;
|
unsigned int filter_to_do = png_ptr->do_filter;
|
||||||
png_bytep row_buf;
|
png_bytep row_buf;
|
||||||
png_bytep best_row;
|
png_bytep best_row;
|
||||||
png_uint_32 bpp;
|
png_uint_32 bpp;
|
||||||
@ -2443,32 +2572,33 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
*/
|
*/
|
||||||
best_row = png_ptr->row_buf;
|
best_row = png_ptr->row_buf;
|
||||||
|
|
||||||
|
if (PNG_SIZE_MAX/128 <= row_bytes)
|
||||||
if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
|
|
||||||
{
|
{
|
||||||
|
/* Overflow can occur in the calculation, just select the lowest set
|
||||||
|
* filter.
|
||||||
|
*/
|
||||||
|
filter_to_do &= 0U-filter_to_do;
|
||||||
|
}
|
||||||
|
else if ((filter_to_do & PNG_FILTER_NONE) != 0 &&
|
||||||
|
filter_to_do != PNG_FILTER_NONE)
|
||||||
|
{
|
||||||
|
/* Overflow not possible and multiple filters in the list, including the
|
||||||
|
* 'none' filter.
|
||||||
|
*/
|
||||||
png_bytep rp;
|
png_bytep rp;
|
||||||
png_size_t sum = 0;
|
png_size_t sum = 0;
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
if (PNG_SIZE_MAX/128 <= row_bytes)
|
|
||||||
{
|
|
||||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
|
||||||
{
|
|
||||||
/* Check for overflow */
|
|
||||||
if (sum > PNG_SIZE_MAX/128 - 256)
|
|
||||||
break;
|
|
||||||
|
|
||||||
v = *rp;
|
|
||||||
sum += (v < 128) ? v : 256 - v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* Overflow is not possible */
|
|
||||||
{
|
{
|
||||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
||||||
{
|
{
|
||||||
v = *rp;
|
v = *rp;
|
||||||
|
#ifdef PNG_USE_ABS
|
||||||
|
sum += 128 - abs(v - 128);
|
||||||
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2479,7 +2609,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
if (filter_to_do == PNG_FILTER_SUB)
|
if (filter_to_do == PNG_FILTER_SUB)
|
||||||
/* It's the only filter so no testing is needed */
|
/* It's the only filter so no testing is needed */
|
||||||
{
|
{
|
||||||
(void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins);
|
png_setup_sub_row_only(png_ptr, bpp, row_bytes);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2505,7 +2635,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
/* Up filter */
|
/* Up filter */
|
||||||
if (filter_to_do == PNG_FILTER_UP)
|
if (filter_to_do == PNG_FILTER_UP)
|
||||||
{
|
{
|
||||||
(void) png_setup_up_row(png_ptr, row_bytes, mins);
|
png_setup_up_row_only(png_ptr, row_bytes);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2531,7 +2661,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
/* Avg filter */
|
/* Avg filter */
|
||||||
if (filter_to_do == PNG_FILTER_AVG)
|
if (filter_to_do == PNG_FILTER_AVG)
|
||||||
{
|
{
|
||||||
(void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins);
|
png_setup_avg_row_only(png_ptr, bpp, row_bytes);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2555,9 +2685,9 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Paeth filter */
|
/* Paeth filter */
|
||||||
if ((filter_to_do == PNG_FILTER_PAETH) != 0)
|
if (filter_to_do == PNG_FILTER_PAETH)
|
||||||
{
|
{
|
||||||
(void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins);
|
png_setup_paeth_row_only(png_ptr, bpp, row_bytes);
|
||||||
best_row = png_ptr->try_row;
|
best_row = png_ptr->try_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,453 +0,0 @@
|
|||||||
<!-- kind:binary;verdict:compatible;affected:0;added:0;removed:0;type_problems_high:0;type_problems_medium:0;type_problems_low:0;interface_problems_high:0;interface_problems_medium:0;interface_problems_low:0;changed_constants:0;tool_version:1.99.15 -->
|
|
||||||
<!-- kind:source;verdict:compatible;affected:0;added:0;removed:0;type_problems_high:0;type_problems_medium:0;type_problems_low:0;interface_problems_high:0;interface_problems_medium:0;interface_problems_low:0;changed_constants:0;tool_version:1.99.15 -->
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<meta name="keywords" content="openjpeg, compatibility, API, ABI, report" />
|
|
||||||
<meta name="description" content="API/ABI compatibility report for the openjpeg object between 2.1 and current versions" />
|
|
||||||
<title>
|
|
||||||
openjpeg: 2.1 to current compatibility report
|
|
||||||
</title>
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
font-family:Arial, sans-serif;
|
|
||||||
background-color:White;
|
|
||||||
color:Black;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
color:Black;
|
|
||||||
background-color:Black;
|
|
||||||
height:1px;
|
|
||||||
border:0;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
margin-bottom:0px;
|
|
||||||
padding-bottom:0px;
|
|
||||||
font-size:1.625em;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
margin-bottom:0px;
|
|
||||||
padding-bottom:0px;
|
|
||||||
font-size:1.25em;
|
|
||||||
white-space:nowrap;
|
|
||||||
}
|
|
||||||
span.section {
|
|
||||||
font-weight:bold;
|
|
||||||
cursor:pointer;
|
|
||||||
color:#003E69;
|
|
||||||
white-space:nowrap;
|
|
||||||
margin-left:5px;
|
|
||||||
}
|
|
||||||
span.new_sign {
|
|
||||||
font-weight:bold;
|
|
||||||
margin-left:26px;
|
|
||||||
color:#003E69;
|
|
||||||
}
|
|
||||||
span.new_sign_lbl {
|
|
||||||
margin-left:28px;
|
|
||||||
font-size:0.875em;
|
|
||||||
color:Black;
|
|
||||||
}
|
|
||||||
span:hover.section {
|
|
||||||
color:#336699;
|
|
||||||
}
|
|
||||||
span.section_affected {
|
|
||||||
cursor:pointer;
|
|
||||||
margin-left:7px;
|
|
||||||
padding-left:15px;
|
|
||||||
font-size:0.875em;
|
|
||||||
color:#cc3300;
|
|
||||||
}
|
|
||||||
span.section_info {
|
|
||||||
cursor:pointer;
|
|
||||||
margin-left:7px;
|
|
||||||
padding-left:15px;
|
|
||||||
font-size:0.875em;
|
|
||||||
color:Black;
|
|
||||||
}
|
|
||||||
span.extendable {
|
|
||||||
font-weight:100;
|
|
||||||
}
|
|
||||||
span.h_name {
|
|
||||||
color:#cc3300;
|
|
||||||
font-size:0.875em;
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
div.h_list, div.lib_list {
|
|
||||||
font-size:0.94em;
|
|
||||||
padding-left:5px;
|
|
||||||
}
|
|
||||||
span.ns {
|
|
||||||
color:#408080;
|
|
||||||
font-size:0.94em;
|
|
||||||
}
|
|
||||||
span.lib_name {
|
|
||||||
color:Green;
|
|
||||||
font-size:0.875em;
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
span.iname {
|
|
||||||
font-weight:bold;
|
|
||||||
color:#003E69;
|
|
||||||
margin-left:5px;
|
|
||||||
}
|
|
||||||
span.iname_b {
|
|
||||||
font-weight:bold;
|
|
||||||
font-size:1.1em;
|
|
||||||
}
|
|
||||||
span.iname_a {
|
|
||||||
color:#333333;
|
|
||||||
font-weight:bold;
|
|
||||||
font-size:0.94em;
|
|
||||||
}
|
|
||||||
span.sym_p {
|
|
||||||
font-weight:normal;
|
|
||||||
white-space:normal;
|
|
||||||
}
|
|
||||||
div.affect {
|
|
||||||
padding-left:15px;
|
|
||||||
padding-bottom:10px;
|
|
||||||
font-size:0.87em;
|
|
||||||
font-style:italic;
|
|
||||||
line-height:0.75em;
|
|
||||||
}
|
|
||||||
div.affected {
|
|
||||||
padding-left:30px;
|
|
||||||
padding-top:10px;
|
|
||||||
}
|
|
||||||
table.ptable {
|
|
||||||
border-collapse:collapse;
|
|
||||||
border:1px outset black;
|
|
||||||
line-height:1em;
|
|
||||||
margin-left:15px;
|
|
||||||
margin-top:3px;
|
|
||||||
margin-bottom:3px;
|
|
||||||
width:900px;
|
|
||||||
|
|
||||||
}
|
|
||||||
table.ptable td {
|
|
||||||
border:1px solid gray;
|
|
||||||
padding: 3px;
|
|
||||||
font-size:0.875em;
|
|
||||||
}
|
|
||||||
table.vtable {
|
|
||||||
border-collapse:collapse;
|
|
||||||
border:1px outset black;
|
|
||||||
line-height:16px;
|
|
||||||
margin-left:30px;
|
|
||||||
margin-top:10px;
|
|
||||||
}
|
|
||||||
table.vtable td {
|
|
||||||
border:1px solid gray;
|
|
||||||
word-wrap:break-word;
|
|
||||||
padding: 3px;
|
|
||||||
font-size:0.875em;
|
|
||||||
max-width:450px;
|
|
||||||
vertical-align:top;
|
|
||||||
}
|
|
||||||
table.ptable th, table.vtable th {
|
|
||||||
background-color:#eeeeee;
|
|
||||||
font-weight:bold;
|
|
||||||
color:#333333;
|
|
||||||
font-family:Verdana, Arial;
|
|
||||||
font-size:0.81em;
|
|
||||||
border:1px solid gray;
|
|
||||||
text-align:center;
|
|
||||||
vertical-align:top;
|
|
||||||
white-space:nowrap;
|
|
||||||
padding: 3px;
|
|
||||||
}
|
|
||||||
table.summary {
|
|
||||||
border-collapse:collapse;
|
|
||||||
border:1px outset black;
|
|
||||||
}
|
|
||||||
table.summary th {
|
|
||||||
background-color:#eeeeee;
|
|
||||||
font-weight:100;
|
|
||||||
text-align:left;
|
|
||||||
font-size:0.94em;
|
|
||||||
white-space:nowrap;
|
|
||||||
border:1px inset gray;
|
|
||||||
padding: 3px;
|
|
||||||
}
|
|
||||||
table.summary td {
|
|
||||||
text-align:right;
|
|
||||||
white-space:nowrap;
|
|
||||||
border:1px inset gray;
|
|
||||||
padding: 3px 5px 3px 10px;
|
|
||||||
}
|
|
||||||
span.mangled {
|
|
||||||
padding-left:15px;
|
|
||||||
font-size:0.875em;
|
|
||||||
cursor:text;
|
|
||||||
color:#444444;
|
|
||||||
}
|
|
||||||
span.sym_ver {
|
|
||||||
color:#333333;
|
|
||||||
white-space:nowrap;
|
|
||||||
font-family:"DejaVu Sans Mono", Monospace;
|
|
||||||
}
|
|
||||||
span.attr {
|
|
||||||
color:#333333;
|
|
||||||
font-weight:100;
|
|
||||||
}
|
|
||||||
span.color_p {
|
|
||||||
font-style:italic;
|
|
||||||
color:Brown;
|
|
||||||
}
|
|
||||||
span.param {
|
|
||||||
font-style:italic;
|
|
||||||
}
|
|
||||||
span.focus_p {
|
|
||||||
font-style:italic;
|
|
||||||
/* color:Red; */
|
|
||||||
background-color:#FFCCCC;
|
|
||||||
}
|
|
||||||
span.ttype {
|
|
||||||
font-weight:100;
|
|
||||||
}
|
|
||||||
span.nowrap {
|
|
||||||
white-space:nowrap;
|
|
||||||
}
|
|
||||||
span.value {
|
|
||||||
white-space:nowrap;
|
|
||||||
font-weight:bold;
|
|
||||||
}
|
|
||||||
td.passed {
|
|
||||||
background-color:#CCFFCC;
|
|
||||||
}
|
|
||||||
td.warning {
|
|
||||||
background-color:#F4F4AF;
|
|
||||||
}
|
|
||||||
td.failed {
|
|
||||||
background-color:#FFCCCC;
|
|
||||||
}
|
|
||||||
td.new {
|
|
||||||
background-color:#C6DEFF;
|
|
||||||
}
|
|
||||||
.top_ref {
|
|
||||||
font-size:0.69em;
|
|
||||||
}
|
|
||||||
.footer {
|
|
||||||
font-size:0.75em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tabset {
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
a.tab {
|
|
||||||
border:1px solid Black;
|
|
||||||
float:left;
|
|
||||||
margin:0px 5px -1px 0px;
|
|
||||||
padding:3px 5px 3px 5px;
|
|
||||||
position:relative;
|
|
||||||
font-size:0.875em;
|
|
||||||
background-color:#DDD;
|
|
||||||
text-decoration:none;
|
|
||||||
color:Black;
|
|
||||||
}
|
|
||||||
a.disabled:hover
|
|
||||||
{
|
|
||||||
color:Black;
|
|
||||||
background:#EEE;
|
|
||||||
}
|
|
||||||
a.active:hover
|
|
||||||
{
|
|
||||||
color:Black;
|
|
||||||
background:White;
|
|
||||||
}
|
|
||||||
a.active {
|
|
||||||
border-bottom-color:White;
|
|
||||||
background-color:White;
|
|
||||||
}
|
|
||||||
div.tab {
|
|
||||||
border-top:1px solid Black;
|
|
||||||
padding:0px;
|
|
||||||
width:100%;
|
|
||||||
clear:both;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
<script type="text/javascript" language="JavaScript">
|
|
||||||
<!--
|
|
||||||
function showContent(header, id)
|
|
||||||
{
|
|
||||||
e = document.getElementById(id);
|
|
||||||
if(e.style.display == 'none')
|
|
||||||
{
|
|
||||||
e.style.display = 'block';
|
|
||||||
e.style.visibility = 'visible';
|
|
||||||
header.innerHTML = header.innerHTML.replace(/\[[^0-9 ]\]/gi,"[−]");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.style.display = 'none';
|
|
||||||
e.style.visibility = 'hidden';
|
|
||||||
header.innerHTML = header.innerHTML.replace(/\[[^0-9 ]\]/gi,"[+]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function initTabs()
|
|
||||||
{
|
|
||||||
var url = window.location.href;
|
|
||||||
if(url.indexOf('_Source_')!=-1 || url.indexOf('#Source')!=-1)
|
|
||||||
{
|
|
||||||
var tab1 = document.getElementById('BinaryID');
|
|
||||||
var tab2 = document.getElementById('SourceID');
|
|
||||||
tab1.className='tab disabled';
|
|
||||||
tab2.className='tab active';
|
|
||||||
}
|
|
||||||
var sets = document.getElementsByTagName('div');
|
|
||||||
for (var i = 0; i < sets.length; i++)
|
|
||||||
{
|
|
||||||
if (sets[i].className.indexOf('tabset') != -1)
|
|
||||||
{
|
|
||||||
var tabs = [];
|
|
||||||
var links = sets[i].getElementsByTagName('a');
|
|
||||||
for (var j = 0; j < links.length; j++)
|
|
||||||
{
|
|
||||||
if (links[j].className.indexOf('tab') != -1)
|
|
||||||
{
|
|
||||||
tabs.push(links[j]);
|
|
||||||
links[j].tabs = tabs;
|
|
||||||
var tab = document.getElementById(links[j].href.substr(links[j].href.indexOf('#') + 1));
|
|
||||||
//reset all tabs on start
|
|
||||||
if (tab)
|
|
||||||
{
|
|
||||||
if (links[j].className.indexOf('active')!=-1) {
|
|
||||||
tab.style.display = 'block';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tab.style.display = 'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
links[j].onclick = function()
|
|
||||||
{
|
|
||||||
var tab = document.getElementById(this.href.substr(this.href.indexOf('#') + 1));
|
|
||||||
if (tab)
|
|
||||||
{
|
|
||||||
//reset all tabs before change
|
|
||||||
for (var k = 0; k < this.tabs.length; k++)
|
|
||||||
{
|
|
||||||
document.getElementById(this.tabs[k].href.substr(this.tabs[k].href.indexOf('#') + 1)).style.display = 'none';
|
|
||||||
this.tabs[k].className = this.tabs[k].className.replace('active', 'disabled');
|
|
||||||
}
|
|
||||||
this.className = 'tab active';
|
|
||||||
tab.style.display = 'block';
|
|
||||||
// window.location.hash = this.id.replace('ID', '');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(url.indexOf('#')!=-1) {
|
|
||||||
location.href=location.href;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (window.addEventListener) window.addEventListener('load', initTabs, false);
|
|
||||||
else if (window.attachEvent) window.attachEvent('onload', initTabs);
|
|
||||||
-->
|
|
||||||
</script>
|
|
||||||
</head><body><a name='Source'></a><a name='Binary'></a><a name='Top'></a><h1>API compatibility report for the <span style='color:Blue;'>libopenjp2.so</span> object between <span style='color:Red;'>2.1</span> and <span style='color:Red;'>current</span> versions on <span style='color:Blue;'>x86_64</span></h1>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
<div class='tabset'>
|
|
||||||
<a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
|
|
||||||
<a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
|
|
||||||
</div><div id='BinaryTab' class='tab'>
|
|
||||||
<h2>Test Info</h2><hr/>
|
|
||||||
<table class='summary'>
|
|
||||||
<tr><th>Module Name</th><td>openjpeg</td></tr>
|
|
||||||
<tr><th>Version #1</th><td>2.1</td></tr>
|
|
||||||
<tr><th>Version #2</th><td>current</td></tr>
|
|
||||||
<tr><th>CPU Type</th><td>x86_64</td></tr>
|
|
||||||
<tr><th>GCC Version</th><td>4.9.2</td></tr>
|
|
||||||
<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>
|
|
||||||
</table>
|
|
||||||
<h2>Test Results</h2><hr/>
|
|
||||||
<table class='summary'><tr><th>Total Header Files</th><td><a href='#Headers' style='color:Blue;'>1</a></td></tr>
|
|
||||||
<tr><th>Total Source Files</th><td><a href='#Sources' style='color:Blue;'>3</a></td></tr>
|
|
||||||
<tr><th>Total Objects</th><td><a href='#Libs' style='color:Blue;'>1</a></td></tr>
|
|
||||||
<tr><th>Total Symbols / Types</th><td>43 / 110</td></tr>
|
|
||||||
<tr><th>Verdict</th><td><span style='color:Green;'><b>Compatible</b></span></td></tr>
|
|
||||||
</table>
|
|
||||||
<h2>Problem Summary</h2><hr/>
|
|
||||||
<table class='summary'><tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr><tr><th>Added Symbols</th><td>-</td><td>0</td></tr>
|
|
||||||
<tr><th>Removed Symbols</th><td>High</td><td>0</td></tr>
|
|
||||||
<tr><th rowspan='3'>Problems with<br/>Data Types</th><td>High</td><td>0</td></tr>
|
|
||||||
<tr><td>Medium</td><td>0</td></tr>
|
|
||||||
<tr><td>Low</td><td>0</td></tr>
|
|
||||||
<tr><th rowspan='3'>Problems with<br/>Symbols</th><td>High</td><td>0</td></tr>
|
|
||||||
<tr><td>Medium</td><td>0</td></tr>
|
|
||||||
<tr><td>Low</td><td>0</td></tr>
|
|
||||||
<tr><th>Problems with<br/>Constants</th><td>Low</td><td>0</td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a name='Headers'></a><h2>Header Files (1)</h2><hr/>
|
|
||||||
<div class='h_list'>
|
|
||||||
openjpeg.h<br/>
|
|
||||||
</div>
|
|
||||||
<br/><a class='top_ref' href='#Top'>to the top</a><br/>
|
|
||||||
<a name='Sources'></a><h2>Source Files (3)</h2><hr/>
|
|
||||||
<div class='h_list'>
|
|
||||||
cio.c<br/>
|
|
||||||
image.c<br/>
|
|
||||||
openjpeg.c<br/>
|
|
||||||
</div>
|
|
||||||
<br/><a class='top_ref' href='#Top'>to the top</a><br/>
|
|
||||||
<a name='Libs'></a><h2>Objects (1)</h2><hr/>
|
|
||||||
<div class='lib_list'>
|
|
||||||
libopenjp2.so.2.1.0<br/>
|
|
||||||
</div>
|
|
||||||
<br/><a class='top_ref' href='#Top'>to the top</a><br/>
|
|
||||||
<br/><br/><br/></div><div id='SourceTab' class='tab'>
|
|
||||||
<h2>Test Info</h2><hr/>
|
|
||||||
<table class='summary'>
|
|
||||||
<tr><th>Module Name</th><td>openjpeg</td></tr>
|
|
||||||
<tr><th>Version #1</th><td>2.1</td></tr>
|
|
||||||
<tr><th>Version #2</th><td>current</td></tr>
|
|
||||||
<tr><th>CPU Type</th><td>x86_64</td></tr>
|
|
||||||
<tr><th>GCC Version</th><td>4.9.2</td></tr>
|
|
||||||
<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>
|
|
||||||
</table>
|
|
||||||
<h2>Test Results</h2><hr/>
|
|
||||||
<table class='summary'><tr><th>Total Header Files</th><td><a href='#Headers' style='color:Blue;'>1</a></td></tr>
|
|
||||||
<tr><th>Total Source Files</th><td><a href='#Sources' style='color:Blue;'>3</a></td></tr>
|
|
||||||
<tr><th>Total Objects</th><td><a href='#Libs' style='color:Blue;'>1</a></td></tr>
|
|
||||||
<tr><th>Total Symbols / Types</th><td>43 / 110</td></tr>
|
|
||||||
<tr><th>Verdict</th><td><span style='color:Green;'><b>Compatible</b></span></td></tr>
|
|
||||||
</table>
|
|
||||||
<h2>Problem Summary</h2><hr/>
|
|
||||||
<table class='summary'><tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr><tr><th>Added Symbols</th><td>-</td><td>0</td></tr>
|
|
||||||
<tr><th>Removed Symbols</th><td>High</td><td>0</td></tr>
|
|
||||||
<tr><th rowspan='3'>Problems with<br/>Data Types</th><td>High</td><td>0</td></tr>
|
|
||||||
<tr><td>Medium</td><td>0</td></tr>
|
|
||||||
<tr><td>Low</td><td>0</td></tr>
|
|
||||||
<tr><th rowspan='3'>Problems with<br/>Symbols</th><td>High</td><td>0</td></tr>
|
|
||||||
<tr><td>Medium</td><td>0</td></tr>
|
|
||||||
<tr><td>Low</td><td>0</td></tr>
|
|
||||||
<tr><th>Problems with<br/>Constants</th><td>Low</td><td>0</td></tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a name='Headers'></a><h2>Header Files (1)</h2><hr/>
|
|
||||||
<div class='h_list'>
|
|
||||||
openjpeg.h<br/>
|
|
||||||
</div>
|
|
||||||
<br/><a class='top_ref' href='#Top'>to the top</a><br/>
|
|
||||||
<a name='Sources'></a><h2>Source Files (3)</h2><hr/>
|
|
||||||
<div class='h_list'>
|
|
||||||
cio.c<br/>
|
|
||||||
image.c<br/>
|
|
||||||
openjpeg.c<br/>
|
|
||||||
</div>
|
|
||||||
<br/><a class='top_ref' href='#Top'>to the top</a><br/>
|
|
||||||
<a name='Libs'></a><h2>Objects (1)</h2><hr/>
|
|
||||||
<div class='lib_list'>
|
|
||||||
libopenjp2.so.2.1.0<br/>
|
|
||||||
</div>
|
|
||||||
<br/><a class='top_ref' href='#Top'>to the top</a><br/>
|
|
||||||
<br/><br/><br/></div><hr/><div class='footer' align='right'><i>Generated on Mon Jan 25 14:47:00 2016 by <a href='http://lvc.github.io/abi-compliance-checker/'>ABI Compliance Checker</a> 1.99.15  </i></div><br/>
|
|
||||||
|
|
||||||
</body></html>
|
|
@ -5,8 +5,8 @@
|
|||||||
"Git": "https://github.com/uclouvain/openjpeg.git",
|
"Git": "https://github.com/uclouvain/openjpeg.git",
|
||||||
"Maintainer": "OpenJPEG team",
|
"Maintainer": "OpenJPEG team",
|
||||||
"MaintainerUrl": "http://www.openjpeg.org/",
|
"MaintainerUrl": "http://www.openjpeg.org/",
|
||||||
"Package": "version.",
|
|
||||||
"Configure": "-DCMAKE_C_FLAGS='-fvisibility=hidden -g -Og -w -fpermissive'",
|
"Configure": "-DCMAKE_C_FLAGS='-fvisibility=hidden -g -Og -w -fpermissive'",
|
||||||
|
"Package": "version.",
|
||||||
|
|
||||||
"Versions": [
|
"Versions": [
|
||||||
{
|
{
|
||||||
@ -21,10 +21,22 @@
|
|||||||
"PublicSymbols": "public_symbols/openjpeg/current/list",
|
"PublicSymbols": "public_symbols/openjpeg/current/list",
|
||||||
"PublicTypes": "public_types/openjpeg/current/list"
|
"PublicTypes": "public_types/openjpeg/current/list"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Number": "2.1.2",
|
||||||
|
"Installed": "installed/openjpeg/2.1.2",
|
||||||
|
"Source": "src/openjpeg/2.1.2/version.-2.1.2.tar.gz",
|
||||||
|
"Changelog": "CHANGELOG.md",
|
||||||
|
"HeadersDiff": "On",
|
||||||
|
"PkgDiff": "Off",
|
||||||
|
"ABIView": "Off",
|
||||||
|
"ABIDiff": "Off",
|
||||||
|
"PublicSymbols": "public_symbols/openjpeg/2.1.2/list",
|
||||||
|
"PublicTypes": "public_types/openjpeg/2.1.2/list"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Number": "2.1.1",
|
"Number": "2.1.1",
|
||||||
"Installed": "installed/openjpeg/2.1.1",
|
"Installed": "installed/openjpeg/2.1.1",
|
||||||
"Source": "src/openjpeg/2.1.1/v2.1.1.tar.gz",
|
"Source": "src/openjpeg/2.1.1/version.-2.1.1.tar.gz",
|
||||||
"Changelog": "CHANGELOG.md",
|
"Changelog": "CHANGELOG.md",
|
||||||
"HeadersDiff": "On",
|
"HeadersDiff": "On",
|
||||||
"PkgDiff": "Off",
|
"PkgDiff": "Off",
|
||||||
@ -104,29 +116,5 @@
|
|||||||
"ABIDiff": "Off",
|
"ABIDiff": "Off",
|
||||||
"PublicSymbols": "public_symbols/openjpeg/1.5/list",
|
"PublicSymbols": "public_symbols/openjpeg/1.5/list",
|
||||||
"PublicTypes": "public_types/openjpeg/1.5/list"
|
"PublicTypes": "public_types/openjpeg/1.5/list"
|
||||||
},
|
|
||||||
{
|
|
||||||
"Number": "1.4",
|
|
||||||
"Installed": "installed/openjpeg/1.4",
|
|
||||||
"Source": "src/openjpeg/1.4/version.1.4.tar.gz",
|
|
||||||
"Changelog": "CHANGES",
|
|
||||||
"HeadersDiff": "On",
|
|
||||||
"PkgDiff": "Off",
|
|
||||||
"ABIView": "Off",
|
|
||||||
"ABIDiff": "Off",
|
|
||||||
"PublicSymbols": "public_symbols/openjpeg/1.4/list",
|
|
||||||
"PublicTypes": "public_types/openjpeg/1.4/list"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Number": "1.2",
|
|
||||||
"Installed": "installed/openjpeg/1.2",
|
|
||||||
"Source": "src/openjpeg/1.2/version.1.2.tar.gz",
|
|
||||||
"Changelog": "ChangeLog",
|
|
||||||
"HeadersDiff": "On",
|
|
||||||
"PkgDiff": "Off",
|
|
||||||
"ABIView": "Off",
|
|
||||||
"ABIDiff": "Off",
|
|
||||||
"PublicSymbols": "public_symbols/openjpeg/1.2/list",
|
|
||||||
"PublicTypes": "public_types/openjpeg/1.2/list"
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ if [ "${OPJ_CI_ABI_CHECK:-}" != "1" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
OPJ_UPLOAD_ABI_REPORT=0
|
OPJ_UPLOAD_ABI_REPORT=0
|
||||||
#OPJ_PREVIOUS_VERSION="2.1"
|
#OPJ_PREVIOUS_VERSION="2.1.1"
|
||||||
OPJ_LATEST_VERSION="2.1.1"
|
OPJ_LATEST_VERSION="2.1.2"
|
||||||
if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
|
if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
|
||||||
OPJ_LIMIT_ABI_BUILDS="-limit 3"
|
OPJ_LIMIT_ABI_BUILDS="-limit 3"
|
||||||
else
|
else
|
||||||
@ -26,7 +26,7 @@ OPJ_SSH_REPO=${OPJ_REPO/https:\/\/github.com\//git@github.com:}
|
|||||||
OPJ_UPLOAD_BRANCH="gh-pages"
|
OPJ_UPLOAD_BRANCH="gh-pages"
|
||||||
OPJ_UPLOAD_DIR="abi-check"
|
OPJ_UPLOAD_DIR="abi-check"
|
||||||
if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
|
if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
|
||||||
if [ "$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')" == "uclouvain" ] && [ "${TRAVIS_PULL_REQUEST:-}" == "false" ]; then
|
if [ "$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')" == "uclouvain" ] && [ "${TRAVIS_PULL_REQUEST:-}" == "false" ] && [ "${TRAVIS_BRANCH:-}" == "master" ]; then
|
||||||
# Upload updated report to gh-pages
|
# Upload updated report to gh-pages
|
||||||
OPJ_UPLOAD_ABI_REPORT=1
|
OPJ_UPLOAD_ABI_REPORT=1
|
||||||
# Build full report
|
# Build full report
|
||||||
@ -71,7 +71,7 @@ rm -rf installed/openjpeg/current/*
|
|||||||
|
|
||||||
# Let's create all we need
|
# Let's create all we need
|
||||||
grep -v Git ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json > ./openjpeg.json
|
grep -v Git ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json > ./openjpeg.json
|
||||||
#abi-monitor ${OPJ_LIMIT_ABI_BUILDS} -get openjpeg.json
|
abi-monitor ${OPJ_LIMIT_ABI_BUILDS} -get openjpeg.json
|
||||||
if [ "${OPJ_LIMIT_ABI_BUILDS}" != "" ]; then
|
if [ "${OPJ_LIMIT_ABI_BUILDS}" != "" ]; then
|
||||||
cp -f ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json ./openjpeg.json
|
cp -f ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json ./openjpeg.json
|
||||||
else
|
else
|
||||||
@ -79,7 +79,11 @@ else
|
|||||||
grep -v Configure ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json > ./openjpeg.json
|
grep -v Configure ${OPJ_SOURCE_DIR}/tools/abi-tracker/openjpeg.json > ./openjpeg.json
|
||||||
fi
|
fi
|
||||||
cp -rf ${OPJ_SOURCE_DIR} src/openjpeg/current
|
cp -rf ${OPJ_SOURCE_DIR} src/openjpeg/current
|
||||||
abi-monitor ${OPJ_LIMIT_ABI_BUILDS} -rebuild openjpeg.json
|
abi-monitor -v current -build openjpeg.json
|
||||||
|
abi-monitor -v ${OPJ_LATEST_VERSION} -build openjpeg.json
|
||||||
|
if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
|
||||||
|
abi-monitor -v ${OPJ_PREVIOUS_VERSION} -build openjpeg.json
|
||||||
|
fi
|
||||||
abi-tracker -build openjpeg.json
|
abi-tracker -build openjpeg.json
|
||||||
|
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user