Compare commits
147 Commits
codingstyl
...
main
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 | ||
![]() |
fef144283f | ||
![]() |
4c5a1cc825 | ||
![]() |
bd96ed8353 | ||
![]() |
f4a708ba0f | ||
![]() |
2372cb78a0 | ||
![]() |
9d5002f8fd | ||
![]() |
e4c74f5364 | ||
![]() |
cb72c08472 | ||
![]() |
898ca6f522 | ||
![]() |
86698be6e9 | ||
![]() |
cdcb77e796 | ||
![]() |
954dad66de | ||
![]() |
48744a1342 | ||
![]() |
7d3c7a345f | ||
![]() |
69497d35c0 | ||
![]() |
d67cd2220a | ||
![]() |
e3eb0a206d | ||
![]() |
57b216bb58 | ||
![]() |
5fbb8b2645 | ||
![]() |
d4b7f03cfa | ||
![]() |
54179fe1d5 | ||
![]() |
7092f7ea11 | ||
![]() |
107eb31531 | ||
![]() |
8371491a99 | ||
![]() |
956c31d5a6 | ||
![]() |
93f7f90711 | ||
![]() |
1da397e94a | ||
![]() |
31882ad7f4 | ||
![]() |
ba1edf6cd4 | ||
![]() |
23a01dfdef | ||
![]() |
d8fef96f23 | ||
![]() |
c539808d09 | ||
![]() |
426bf8d337 | ||
![]() |
d0babeb6f6 | ||
![]() |
d1ca2b4f29 | ||
![]() |
8ba0de3e45 | ||
![]() |
2e0779e250 | ||
![]() |
e55130d3c5 | ||
![]() |
4d2b6a671a | ||
![]() |
aae066debc | ||
![]() |
6609719b40 | ||
![]() |
1a8318f6c2 | ||
![]() |
162f6199c0 | ||
![]() |
8f9cc62b3f | ||
![]() |
44a499f2ac | ||
![]() |
94cfb1b008 | ||
![]() |
17a0a8a195 | ||
![]() |
ba0cf122f6 | ||
![]() |
da56086e01 | ||
![]() |
04b8cbd27a | ||
![]() |
e1e018a8dc | ||
![]() |
b51d088267 | ||
![]() |
4f11e89c80 | ||
![]() |
9a20f8e8d1 | ||
![]() |
72deb588cb | ||
![]() |
cd77b6003b | ||
![]() |
f40a2ff2ad | ||
![]() |
be42e72d22 | ||
![]() |
15f081c896 | ||
![]() |
ad593c9e06 | ||
![]() |
319fc971fe | ||
![]() |
e166e4a209 | ||
![]() |
29313eb5f1 | ||
![]() |
e982d03966 | ||
![]() |
66fd497765 | ||
![]() |
20789fed4e | ||
![]() |
5947e10ff7 | ||
![]() |
e6881e7527 | ||
![]() |
2296dc9e68 | ||
![]() |
6f2ac3ee36 | ||
![]() |
c559c62853 | ||
![]() |
a9feb9addd | ||
![]() |
74e814358c | ||
![]() |
54393d9e38 | ||
![]() |
06e8dc9edd | ||
![]() |
f5446fdcfb | ||
![]() |
8611d127db | ||
![]() |
889bf16791 | ||
![]() |
6ea2ff0b06 | ||
![]() |
3436c4e9ba | ||
![]() |
e1a93d9e59 | ||
![]() |
a1c0ee9a86 | ||
![]() |
40b5a53d2f | ||
![]() |
e7797b97a1 | ||
![]() |
5e5f6999a8 | ||
![]() |
0069a2bd2f | ||
![]() |
e3100f714c |
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Ignore files and directories made by `cmake .`.
|
||||
CMakeFiles/
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
/CMakeCache.txt
|
||||
/CPackConfig.cmake
|
||||
/CPackSourceConfig.cmake
|
||||
/CTestCustom.cmake
|
||||
/LICENSE.txt
|
||||
/OpenJPEGConfig.cmake
|
||||
/libopenjp2.pc
|
||||
/src/bin/common/opj_apps_config.h
|
||||
/src/lib/openjp2/opj_config.h
|
||||
/src/lib/openjp2/opj_config_private.h
|
||||
|
||||
# Ignore directories made by `make`.
|
||||
/bin/
|
34
.travis.yml
34
.travis.yml
@ -4,10 +4,13 @@ matrix:
|
||||
include:
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
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
|
||||
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
|
||||
compiler: gcc
|
||||
env: OPJ_CI_ARCH=i386 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
@ -21,6 +24,16 @@ matrix:
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Debug OPJ_CI_ASAN=1
|
||||
- os: linux
|
||||
compiler: clang-3.8
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.8
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang-3.8
|
||||
- os: linux
|
||||
compiler: x86_64-w64-mingw32-gcc
|
||||
env: OPJ_CI_ARCH=x86_64 OPJ_CI_BUILD_CONFIGURATION=Release
|
||||
@ -61,3 +74,20 @@ install:
|
||||
script:
|
||||
- ./tools/travis-ci/run.sh
|
||||
- ./tools/travis-ci/abi-check.sh
|
||||
|
||||
before_deploy:
|
||||
- export OPJ_RELEASE_PKG_FILE=$(ls build/openjpeg-${TRAVIS_TAG}*)
|
||||
- echo "deploying $OPJ_RELEASE_PKG_FILE to GitHub releases"
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: Npi13uOffALCVNwea4p4q8v85Lo/WsRqaeZQcWrAkt8MxRnfvWQtmnuwmHnVB6Cig+T1lVUHrklOaJIApIb6nkGq3CS/9bD8+SCS2NEdAAP/QYWnBi0ubWXVMRyDLypmwRpzLNSZ0xLYGFUl2PjieZYKRcz1dd/J7S+FnXhPtdjXweq0FS63zTcMe7ggjfmzSOWUCEFmMjZPaM0Be+3PweieCO1dxlHuy7ugCkx2S7d+5hNsicIhQmTADjqtJAkHoMhYqu6/yLFxhjO/+f938PATFULdODTvjCsUwdN/ySWi1Oj4uPAntfytZP7H6YrzLh8dS73QCsdkhhDJIgJskHIBSbRyyEVUnOvQgD9VaBVGHtc1KtZQTwc41OUO3BGPHl97s3oX6bqWqo/L53dB3TPHGx+1+2HL/F0zaDZuHhAKMkPwe8LFPMPB/ur65zXMHjnWb2ZTVVdoIvkbQ7nu8ApI60ejxocYBsEyAuC2CPXU2ki4jdEhm0E1hIziWNE9/LTuM17ziQuJ6WpXOSMrfP4o5aVDmLp5ZGBSocrspOksgyI9XogHaO/r+Y6N3exy+giObFfMHkZVUpsKrKmtOJ7TC1Vg5HsYGlWW8RN8dkJV47bUXm9K4sMos9eYMUt/czykPAs+132cogpII3QxXpFZQqZg6SEPVfOiyqQzTUI=
|
||||
file_glob: true
|
||||
file: "${OPJ_RELEASE_PKG_FILE}"
|
||||
skip_cleanup: true
|
||||
on:
|
||||
repo: uclouvain/openjpeg
|
||||
tags: true
|
||||
condition: "$OPJ_CI_INCLUDE_IF_DEPLOY = 1"
|
||||
|
||||
|
@ -1,12 +1,18 @@
|
||||
Authors of OpenJPEG
|
||||
See also the files THANKS and CHANGES
|
||||
# Authors of OpenJPEG
|
||||
See also [THANKS](https://github.com/uclouvain/openjpeg/blob/master/THANKS.md)
|
||||
|
||||
David Janssens designed and implemented the first version of OpenJPEG.
|
||||
|
||||
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
||||
|
||||
Jerome Fimes implemented the alpha version of OpenJPEG 2.0.
|
||||
|
||||
Giuseppe Baruffa added the JPWL functionalities.
|
||||
Mickaël Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
|
||||
|
||||
Mickaël Savinaud implemented the final OpenJPEG 2.0 version based on a big merge between 1.5 version and alpha version of 2.0.
|
||||
|
||||
Mathieu Malaterre participated to the OpenJPEG 2.0 version and improved the libraries and utilities.
|
||||
|
||||
Yannick Verschueren,
|
||||
Herve Drolon,
|
||||
Francois-Olivier Devaux,
|
446
CHANGELOG.md
Normal file
446
CHANGELOG.md
Normal file
@ -0,0 +1,446 @@
|
||||
# Changelog
|
||||
|
||||
## [v2.1.2](https://github.com/uclouvain/openjpeg/releases/v2.1.2) (2016-09-28)
|
||||
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.1.1...v2.1.2)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- null ptr dereference in convert.c:1331 [\#843](https://github.com/uclouvain/openjpeg/issues/843)
|
||||
- Out-of-Bounds Read in function bmp24toimage of convertbmp.c [\#833](https://github.com/uclouvain/openjpeg/issues/833)
|
||||
- Disable automatic compilation of t1\_generate\_luts in CMakeLists.txt [\#831](https://github.com/uclouvain/openjpeg/issues/831)
|
||||
- CVE-2016-7163 Integer overflow in opj\_pi\_create\_decode [\#826](https://github.com/uclouvain/openjpeg/issues/826)
|
||||
- Security Advisory for OpenJPEG [\#810](https://github.com/uclouvain/openjpeg/issues/810)
|
||||
- Add dashboard with static lib [\#804](https://github.com/uclouvain/openjpeg/issues/804)
|
||||
- hidden visibility for the static library / building with -DOPJ\_STATIC against shared lib [\#802](https://github.com/uclouvain/openjpeg/issues/802)
|
||||
- Optimization when building library from source [\#799](https://github.com/uclouvain/openjpeg/issues/799)
|
||||
- unsigned int16 on Solaris 11.2/sparc [\#796](https://github.com/uclouvain/openjpeg/issues/796)
|
||||
- appveyor [\#793](https://github.com/uclouvain/openjpeg/issues/793)
|
||||
- Please make a new release [\#782](https://github.com/uclouvain/openjpeg/issues/782)
|
||||
- FFMpeg will not link to 2.1.1 release built as shared library [\#766](https://github.com/uclouvain/openjpeg/issues/766)
|
||||
- API change since v2: opj\_event\_mgr\_t not available [\#754](https://github.com/uclouvain/openjpeg/issues/754)
|
||||
- openjpeg.h needs dependencies [\#673](https://github.com/uclouvain/openjpeg/issues/673)
|
||||
- "master" does not build on ubuntu [\#658](https://github.com/uclouvain/openjpeg/issues/658)
|
||||
- Package 'openjp2', required by 'libopenjpip', not found [\#594](https://github.com/uclouvain/openjpeg/issues/594)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fix PNM file reading [\#847](https://github.com/uclouvain/openjpeg/pull/847) ([mayeut](https://github.com/mayeut))
|
||||
- Fix some issues reported by Coverity Scan [\#846](https://github.com/uclouvain/openjpeg/pull/846) ([stweil](https://github.com/stweil))
|
||||
- Fix potential out-of-bounds read \(coverity\) [\#844](https://github.com/uclouvain/openjpeg/pull/844) ([stweil](https://github.com/stweil))
|
||||
- Remove TODO for overflow check [\#842](https://github.com/uclouvain/openjpeg/pull/842) ([mayeut](https://github.com/mayeut))
|
||||
- Add overflow checks for opj\_aligned\_malloc [\#841](https://github.com/uclouvain/openjpeg/pull/841) ([mayeut](https://github.com/mayeut))
|
||||
- Flags in T1 shall be unsigned [\#840](https://github.com/uclouvain/openjpeg/pull/840) ([mayeut](https://github.com/mayeut))
|
||||
- Fix some warnings [\#838](https://github.com/uclouvain/openjpeg/pull/838) ([mayeut](https://github.com/mayeut))
|
||||
- Fix issue 833. [\#834](https://github.com/uclouvain/openjpeg/pull/834) ([trylab](https://github.com/trylab))
|
||||
- Add overflow checks for opj\_aligned\_malloc [\#832](https://github.com/uclouvain/openjpeg/pull/832) ([mayeut](https://github.com/mayeut))
|
||||
- Add test for issue 820 [\#829](https://github.com/uclouvain/openjpeg/pull/829) ([mayeut](https://github.com/mayeut))
|
||||
- Add test for issue 826 [\#827](https://github.com/uclouvain/openjpeg/pull/827) ([mayeut](https://github.com/mayeut))
|
||||
- Fix coverity 113065 \(CWE-484\) [\#824](https://github.com/uclouvain/openjpeg/pull/824) ([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))
|
||||
- Update to libpng 1.6.25 [\#821](https://github.com/uclouvain/openjpeg/pull/821) ([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))
|
||||
- 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))
|
||||
- Change 'restrict' define to 'OPJ\_RESTRICT' [\#816](https://github.com/uclouvain/openjpeg/pull/816) ([mayeut](https://github.com/mayeut))
|
||||
- Switch to clang 3.8 [\#814](https://github.com/uclouvain/openjpeg/pull/814) ([mayeut](https://github.com/mayeut))
|
||||
- Fix an integer overflow issue [\#809](https://github.com/uclouvain/openjpeg/pull/809) ([trylab](https://github.com/trylab))
|
||||
- Update to lcms 2.8 [\#808](https://github.com/uclouvain/openjpeg/pull/808) ([mayeut](https://github.com/mayeut))
|
||||
- Update to libpng 1.6.24 [\#807](https://github.com/uclouvain/openjpeg/pull/807) ([mayeut](https://github.com/mayeut))
|
||||
- Reenable clang-3.9 build on travis [\#806](https://github.com/uclouvain/openjpeg/pull/806) ([mayeut](https://github.com/mayeut))
|
||||
- Bit fields type [\#805](https://github.com/uclouvain/openjpeg/pull/805) ([smuehlst](https://github.com/smuehlst))
|
||||
- Add compilation test for standalone inclusion of openjpeg.h [\#798](https://github.com/uclouvain/openjpeg/pull/798) ([mayeut](https://github.com/mayeut))
|
||||
- jpwl: Remove non-portable data type u\_int16\_t \(fix issue \#796\) [\#797](https://github.com/uclouvain/openjpeg/pull/797) ([stweil](https://github.com/stweil))
|
||||
- Fix dependency for pkg-config \(issue \#594\) [\#795](https://github.com/uclouvain/openjpeg/pull/795) ([stweil](https://github.com/stweil))
|
||||
- Add .gitignore [\#787](https://github.com/uclouvain/openjpeg/pull/787) ([stweil](https://github.com/stweil))
|
||||
|
||||
## [v2.1.1](https://github.com/uclouvain/openjpeg/releases/tag/v2.1.1) (2016-07-05)
|
||||
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.1...v2.1.1)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- opj\_malloc replacement [\#625](https://github.com/uclouvain/openjpeg/issues/625)
|
||||
- backport "-p" and "-force-rgb" options in 1.5 [\#606](https://github.com/uclouvain/openjpeg/issues/606)
|
||||
- Use travis-ci matrix build [\#581](https://github.com/uclouvain/openjpeg/issues/581)
|
||||
- Add Coverity Scan analysis [\#580](https://github.com/uclouvain/openjpeg/issues/580)
|
||||
- Unnecessary rate distortion calculations [\#479](https://github.com/uclouvain/openjpeg/issues/479)
|
||||
- Add images from various security issues to test suite [\#415](https://github.com/uclouvain/openjpeg/issues/415)
|
||||
- Coding speed for 9/7 on 32bits platforms \(x86/ARM\) can be improved with a quick fix [\#220](https://github.com/uclouvain/openjpeg/issues/220)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- Out-of-Bounds Access in function opj\_tgt\_reset of tgt.c [\#775](https://github.com/uclouvain/openjpeg/issues/775)
|
||||
- Heap Buffer Overflow in function color\_cmyk\_to\_rgb of color.c [\#774](https://github.com/uclouvain/openjpeg/issues/774)
|
||||
- division-by-zero \(SIGFPE\) error in opj\_tcd\_init\_tile function \(line 730 of tcd.c\) [\#733](https://github.com/uclouvain/openjpeg/issues/733)
|
||||
- Out-Of-Bounds Read in sycc422\_to\_rgb function [\#726](https://github.com/uclouvain/openjpeg/issues/726)
|
||||
- Heap Corruption in opj\_free function [\#725](https://github.com/uclouvain/openjpeg/issues/725)
|
||||
- Out-Of-Bounds Read in opj\_tcd\_free\_tile function [\#724](https://github.com/uclouvain/openjpeg/issues/724)
|
||||
- Cannot handle box of undefined size [\#653](https://github.com/uclouvain/openjpeg/issues/653)
|
||||
- Compilation fails without platform-supplied aligned malloc [\#642](https://github.com/uclouvain/openjpeg/issues/642)
|
||||
- HP compiler warns about redeclaration of static function [\#640](https://github.com/uclouvain/openjpeg/issues/640)
|
||||
- Implementation-defined behavior of malloc causes different behavior on Linux and AIX [\#635](https://github.com/uclouvain/openjpeg/issues/635)
|
||||
- Build on AIX fails because "opj\_includes.h" is included after system headers [\#633](https://github.com/uclouvain/openjpeg/issues/633)
|
||||
- Compiling with SSE2 on Linux 32-bit causes crashes in OpenJPEG [\#624](https://github.com/uclouvain/openjpeg/issues/624)
|
||||
- Build on AIX fails because of "restrict" pointers [\#620](https://github.com/uclouvain/openjpeg/issues/620)
|
||||
- bug in new tif conversion code [\#609](https://github.com/uclouvain/openjpeg/issues/609)
|
||||
- bin/jp2/convert.c line 1085 Resource leak [\#607](https://github.com/uclouvain/openjpeg/issues/607)
|
||||
- bin/jp2/convert.c memory leak [\#601](https://github.com/uclouvain/openjpeg/issues/601)
|
||||
- Resource leak in opj\_j2k\_create\_cstr\_index in case of failure [\#599](https://github.com/uclouvain/openjpeg/issues/599)
|
||||
- Resource leak in opj\_j2k\_encode in case of failure [\#598](https://github.com/uclouvain/openjpeg/issues/598)
|
||||
- Resource leak in opj\_j2k\_decode\_one\_tile in case of failure [\#597](https://github.com/uclouvain/openjpeg/issues/597)
|
||||
- Resource Leak [\#573](https://github.com/uclouvain/openjpeg/issues/573)
|
||||
- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) [\#571](https://github.com/uclouvain/openjpeg/issues/571)
|
||||
- Use-after-free in opj\_j2k\_write\_mco [\#563](https://github.com/uclouvain/openjpeg/issues/563)
|
||||
- openjpeg-master-2015-07-30 failed to compile on LINUX [\#556](https://github.com/uclouvain/openjpeg/issues/556)
|
||||
- PNG images are always read as RGB\(A\) images [\#536](https://github.com/uclouvain/openjpeg/issues/536)
|
||||
- g4\_colr.j2c not handled properly [\#532](https://github.com/uclouvain/openjpeg/issues/532)
|
||||
- Bigendian: opj\_compress + opj\_decompress fails [\#518](https://github.com/uclouvain/openjpeg/issues/518)
|
||||
- Suspicious code in j2k.c [\#517](https://github.com/uclouvain/openjpeg/issues/517)
|
||||
- Decode times almost double\(!!\) on Visual Studio 2013, 2015 [\#505](https://github.com/uclouvain/openjpeg/issues/505)
|
||||
- opj\_data/input/nonregression/issue226.j2k [\#500](https://github.com/uclouvain/openjpeg/issues/500)
|
||||
- opj\_setup\_encoder always returns true [\#497](https://github.com/uclouvain/openjpeg/issues/497)
|
||||
- Double free in j2k\_read\_ppm\_v3 parsing \(\(presumably invalid\) image. [\#496](https://github.com/uclouvain/openjpeg/issues/496)
|
||||
- Invalid write in opj\_j2k\_update\_image\_data [\#495](https://github.com/uclouvain/openjpeg/issues/495)
|
||||
- Undefined printf format specifier %ud used in code [\#494](https://github.com/uclouvain/openjpeg/issues/494)
|
||||
- Potential double free on malloc failure in opj\_j2k\_copy\_default\_tcp\_and\_create\_tcp\(\) [\#492](https://github.com/uclouvain/openjpeg/issues/492)
|
||||
- Do not link with -ffast-math [\#488](https://github.com/uclouvain/openjpeg/issues/488)
|
||||
- Heap-buffer-overflow in opj\_dwt\_decode [\#486](https://github.com/uclouvain/openjpeg/issues/486)
|
||||
- opj\_dump fails on Windows 7, 64 bits [\#482](https://github.com/uclouvain/openjpeg/issues/482)
|
||||
- SIGSEGV in opj\_j2k\_update\_image\_data via pdfium\_test [\#481](https://github.com/uclouvain/openjpeg/issues/481)
|
||||
- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#477](https://github.com/uclouvain/openjpeg/issues/477)
|
||||
- Invalid image causes write past end of heap buffer [\#476](https://github.com/uclouvain/openjpeg/issues/476)
|
||||
- Assertion `l\_res-\>x0 \>= 0' fails when parsing invalid images [\#475](https://github.com/uclouvain/openjpeg/issues/475)
|
||||
- Bug on opj\_write\_bytes\_BE function [\#472](https://github.com/uclouvain/openjpeg/issues/472)
|
||||
- Refactor j2k\_read\_ppm\_v3 function [\#470](https://github.com/uclouvain/openjpeg/issues/470)
|
||||
- compression: strange precinct dimensions [\#466](https://github.com/uclouvain/openjpeg/issues/466)
|
||||
- \(:- Console message in opj\_decompress -:\) [\#465](https://github.com/uclouvain/openjpeg/issues/465)
|
||||
- opj\_decompress fails to decompress any files [\#463](https://github.com/uclouvain/openjpeg/issues/463)
|
||||
- bio-\>ct is unnecessarily set to zero in opj\_bio\_flush method [\#461](https://github.com/uclouvain/openjpeg/issues/461)
|
||||
- Maximal unsigned short is 65535, not 65536 [\#460](https://github.com/uclouvain/openjpeg/issues/460)
|
||||
- OpenJpeg fails to encode components with different precision properly [\#459](https://github.com/uclouvain/openjpeg/issues/459)
|
||||
- component precision upscaling isn't correct in opj\_decompress [\#458](https://github.com/uclouvain/openjpeg/issues/458)
|
||||
- Multiple precision components won't get encoded to jp2 if 1 component is unsigned 1 bit [\#457](https://github.com/uclouvain/openjpeg/issues/457)
|
||||
- Incorrect code in ../bin/jp2/convert.c, function rawtoimage\_common\(...\) [\#456](https://github.com/uclouvain/openjpeg/issues/456)
|
||||
- \[OpenJPEG-trunk\] opj\_stream\_get\_number\_byte\_left throws assert [\#455](https://github.com/uclouvain/openjpeg/issues/455)
|
||||
- NR-DEC-kodak\_2layers\_lrcp.j2c-31-decode-md5 fails randomly when running tests in parallel [\#454](https://github.com/uclouvain/openjpeg/issues/454)
|
||||
- compare\_raw\_files doesn't report an error on invalid arguments / missing input files [\#453](https://github.com/uclouvain/openjpeg/issues/453)
|
||||
- Forward discrete wavelet transform: implement periodic symmetric extension at boundaries [\#452](https://github.com/uclouvain/openjpeg/issues/452)
|
||||
- Bug in tiff reading method in convert.c [\#449](https://github.com/uclouvain/openjpeg/issues/449)
|
||||
- Image in pdf don't display [\#447](https://github.com/uclouvain/openjpeg/issues/447)
|
||||
- Multiple issues causing opj\_decompress to segfault [\#446](https://github.com/uclouvain/openjpeg/issues/446)
|
||||
- opj\_compress: 40% of encode time is spent freeing data [\#445](https://github.com/uclouvain/openjpeg/issues/445)
|
||||
- Multiple warnings when configuring OpenJPEG on MacOS with CMake 3.x \(trunk\) [\#443](https://github.com/uclouvain/openjpeg/issues/443)
|
||||
- valgrind memleak found [\#437](https://github.com/uclouvain/openjpeg/issues/437)
|
||||
- global-buffer-overflow src/lib/openjp2/t1.c:1146 opj\_t1\_getwmsedec [\#436](https://github.com/uclouvain/openjpeg/issues/436)
|
||||
- Warning introduced on trunk r2923 & r2924 [\#435](https://github.com/uclouvain/openjpeg/issues/435)
|
||||
- heap-buffer-overflow in opj\_t1\_decode\_cblks [\#432](https://github.com/uclouvain/openjpeg/issues/432)
|
||||
- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#431](https://github.com/uclouvain/openjpeg/issues/431)
|
||||
- Heap-buffer-overflow in opj\_j2k\_tcp\_destroy [\#430](https://github.com/uclouvain/openjpeg/issues/430)
|
||||
- Heap-buffer-overflow in opj\_jp2\_apply\_pclr [\#429](https://github.com/uclouvain/openjpeg/issues/429)
|
||||
- issue412 revisited [\#428](https://github.com/uclouvain/openjpeg/issues/428)
|
||||
- Image distorted \(sides look cankered\) [\#423](https://github.com/uclouvain/openjpeg/issues/423)
|
||||
- openjpeg-2.x-trunk-r2918 is broken in color.c [\#422](https://github.com/uclouvain/openjpeg/issues/422)
|
||||
- Heap-buffer-overflow in opj\_tcd\_init\_decode\_tile [\#420](https://github.com/uclouvain/openjpeg/issues/420)
|
||||
- Heap-use-after-free in opj\_t1\_decode\_cblks [\#418](https://github.com/uclouvain/openjpeg/issues/418)
|
||||
- UNKNOWN in opj\_read\_bytes\_LE [\#417](https://github.com/uclouvain/openjpeg/issues/417)
|
||||
- Transparency problem [\#416](https://github.com/uclouvain/openjpeg/issues/416)
|
||||
- Image with per channel alpha \(cdef\) does not decode properly [\#414](https://github.com/uclouvain/openjpeg/issues/414)
|
||||
- OpenJPEG crashes with attached image [\#413](https://github.com/uclouvain/openjpeg/issues/413)
|
||||
- Palette image with cdef fails to decompress [\#412](https://github.com/uclouvain/openjpeg/issues/412)
|
||||
- Invalid member values from opj\_read\_header or opj\_decode ? [\#411](https://github.com/uclouvain/openjpeg/issues/411)
|
||||
- MD5 Checksum hangs under valgrind on MacOS X [\#410](https://github.com/uclouvain/openjpeg/issues/410)
|
||||
- Heap-buffer-overflow in opj\_tcd\_get\_decoded\_tile\_size [\#408](https://github.com/uclouvain/openjpeg/issues/408)
|
||||
- C++ style comments in trunk/src/lib/openjp2/j2k.c [\#407](https://github.com/uclouvain/openjpeg/issues/407)
|
||||
- Backport bugfixes from trunk to 2.1 branch [\#405](https://github.com/uclouvain/openjpeg/issues/405)
|
||||
- Heap-buffer-overflow in parse\_cmdline\_encoder [\#403](https://github.com/uclouvain/openjpeg/issues/403)
|
||||
- Heap-buffer-overflow in opj\_v4dwt\_interleave\_h [\#400](https://github.com/uclouvain/openjpeg/issues/400)
|
||||
- Heap-buffer-overflow in opj\_dwt\_decode [\#399](https://github.com/uclouvain/openjpeg/issues/399)
|
||||
- Heap-use-after-free in opj\_t1\_decode\_cblks [\#398](https://github.com/uclouvain/openjpeg/issues/398)
|
||||
- Heap-buffer-overflow in opj\_jp2\_apply\_cdef [\#397](https://github.com/uclouvain/openjpeg/issues/397)
|
||||
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#396](https://github.com/uclouvain/openjpeg/issues/396)
|
||||
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#395](https://github.com/uclouvain/openjpeg/issues/395)
|
||||
- Heap-buffer-overflow in opj\_dwt\_decode\_1 [\#394](https://github.com/uclouvain/openjpeg/issues/394)
|
||||
- Heap-double-free in j2k\_read\_ppm\_v3 [\#393](https://github.com/uclouvain/openjpeg/issues/393)
|
||||
- Security hole in j2k.c [\#392](https://github.com/uclouvain/openjpeg/issues/392)
|
||||
- Security: double-free in opj\_tcd\_code\_block\_dec\_deallocate [\#391](https://github.com/uclouvain/openjpeg/issues/391)
|
||||
- check for negative-size params in code [\#390](https://github.com/uclouvain/openjpeg/issues/390)
|
||||
- Heap-buffer-overflow in opj\_t2\_read\_packet\_header [\#389](https://github.com/uclouvain/openjpeg/issues/389)
|
||||
- Heap overflow in OpenJpeg 1.5.2 [\#388](https://github.com/uclouvain/openjpeg/issues/388)
|
||||
- openjpip.so.6 file too short [\#387](https://github.com/uclouvain/openjpeg/issues/387)
|
||||
- Corrupted JP3D file [\#386](https://github.com/uclouvain/openjpeg/issues/386)
|
||||
- variable assigned to itself [\#383](https://github.com/uclouvain/openjpeg/issues/383)
|
||||
- Null pointer dereferencing [\#382](https://github.com/uclouvain/openjpeg/issues/382)
|
||||
- bad use of case statement [\#381](https://github.com/uclouvain/openjpeg/issues/381)
|
||||
- Release 2.1 as a Ubuntu package [\#380](https://github.com/uclouvain/openjpeg/issues/380)
|
||||
- Bug in libopenjpwl.pc [\#374](https://github.com/uclouvain/openjpeg/issues/374)
|
||||
- inconsistent tile numbering in decode output message [\#370](https://github.com/uclouvain/openjpeg/issues/370)
|
||||
- error in code block calculations [\#369](https://github.com/uclouvain/openjpeg/issues/369)
|
||||
- r2872 fails to compile due to "attempt to use poisoned malloc" error in j2k.c [\#368](https://github.com/uclouvain/openjpeg/issues/368)
|
||||
- OSX build gives libopenjp2.6.dylib with not-absolute install name id [\#367](https://github.com/uclouvain/openjpeg/issues/367)
|
||||
- opj\_decompress gives error but successfully decompress in OPJ 2.1 [\#366](https://github.com/uclouvain/openjpeg/issues/366)
|
||||
- pngtoimage\(\) and imagetopng\(\) have wrong byte order for 16-Bit image [\#365](https://github.com/uclouvain/openjpeg/issues/365)
|
||||
- PDF crash in chrome - part2 \(due to attachment limit\) [\#364](https://github.com/uclouvain/openjpeg/issues/364)
|
||||
- PDF crash in chrome - part1 [\#363](https://github.com/uclouvain/openjpeg/issues/363)
|
||||
- PDF crash in chrome - part0 [\#362](https://github.com/uclouvain/openjpeg/issues/362)
|
||||
- Compilation fails on Windows with mingw32 gcc4.8 [\#361](https://github.com/uclouvain/openjpeg/issues/361)
|
||||
- security issue [\#360](https://github.com/uclouvain/openjpeg/issues/360)
|
||||
- improve memory management [\#359](https://github.com/uclouvain/openjpeg/issues/359)
|
||||
- how to compress a yuv420 raw data using opj\_compress [\#357](https://github.com/uclouvain/openjpeg/issues/357)
|
||||
- Some memory allocation are not checked [\#355](https://github.com/uclouvain/openjpeg/issues/355)
|
||||
- Static library symbols shall be marked as hidden [\#354](https://github.com/uclouvain/openjpeg/issues/354)
|
||||
- opj\_compress rejects valid bmp files [\#353](https://github.com/uclouvain/openjpeg/issues/353)
|
||||
- opj\_compress crashes when number of resolutions is set to zero [\#352](https://github.com/uclouvain/openjpeg/issues/352)
|
||||
- Compilation error under Visual Studio 2003 [\#351](https://github.com/uclouvain/openjpeg/issues/351)
|
||||
- opj\_compress description example error \[Low priority\] [\#350](https://github.com/uclouvain/openjpeg/issues/350)
|
||||
- opj\_write\_bytes\_BE is wrong in trunk [\#345](https://github.com/uclouvain/openjpeg/issues/345)
|
||||
- PART1ONLY option in release.sh doesn't work properly [\#332](https://github.com/uclouvain/openjpeg/issues/332)
|
||||
- openjpeg crash error [\#330](https://github.com/uclouvain/openjpeg/issues/330)
|
||||
- openjpeg decompress error [\#329](https://github.com/uclouvain/openjpeg/issues/329)
|
||||
- openjpeg decompress issue [\#326](https://github.com/uclouvain/openjpeg/issues/326)
|
||||
- limited tif support [\#322](https://github.com/uclouvain/openjpeg/issues/322)
|
||||
- asoc value of 65536 is allowed [\#321](https://github.com/uclouvain/openjpeg/issues/321)
|
||||
- opj\_skip\_from\_file error [\#314](https://github.com/uclouvain/openjpeg/issues/314)
|
||||
- Heavy quota usage in openjpeg [\#309](https://github.com/uclouvain/openjpeg/issues/309)
|
||||
- Verify -help actually match letter [\#307](https://github.com/uclouvain/openjpeg/issues/307)
|
||||
- g3\_colr.j2c not handled [\#288](https://github.com/uclouvain/openjpeg/issues/288)
|
||||
- reopen/fix issue 165 [\#280](https://github.com/uclouvain/openjpeg/issues/280)
|
||||
- kakadu conformance tests [\#279](https://github.com/uclouvain/openjpeg/issues/279)
|
||||
- missing break after case statement in opj\_dwt\_decode\_real [\#274](https://github.com/uclouvain/openjpeg/issues/274)
|
||||
- Run Coverity on trunk [\#270](https://github.com/uclouvain/openjpeg/issues/270)
|
||||
- NR-ENC-random-issue-0005.tif-12-encode [\#259](https://github.com/uclouvain/openjpeg/issues/259)
|
||||
- Use new add\_test signature to handle cross compilation [\#258](https://github.com/uclouvain/openjpeg/issues/258)
|
||||
- Loss decoding quality in 2.0.0 [\#254](https://github.com/uclouvain/openjpeg/issues/254)
|
||||
- Decompress that worked in 1.5.1 fails in 2.0 [\#252](https://github.com/uclouvain/openjpeg/issues/252)
|
||||
- Expected endianness with raw input is not documented leading to SEGFAULT [\#251](https://github.com/uclouvain/openjpeg/issues/251)
|
||||
- OpenJPEG writes to stderr [\#246](https://github.com/uclouvain/openjpeg/issues/246)
|
||||
- Inconsistent logging of tile index [\#245](https://github.com/uclouvain/openjpeg/issues/245)
|
||||
- patch for openjpeg-trunk-r2347 and BIG\_ENDIAN [\#242](https://github.com/uclouvain/openjpeg/issues/242)
|
||||
- CMAP: MTYP == 0 \(direct use\) not handled properly [\#235](https://github.com/uclouvain/openjpeg/issues/235)
|
||||
- Black Pixel [\#233](https://github.com/uclouvain/openjpeg/issues/233)
|
||||
- opj\_compress runtime error after fresh Linux install due to apparent failure to execute ldconfig [\#219](https://github.com/uclouvain/openjpeg/issues/219)
|
||||
- openjp2 debug works, release build does not [\#217](https://github.com/uclouvain/openjpeg/issues/217)
|
||||
- openjpeg-branch15-r2299 and openjpeg-trunk-r2299 fail to decode a JP2 file [\#212](https://github.com/uclouvain/openjpeg/issues/212)
|
||||
- openjpeg-trunk issue with Win7 [\#201](https://github.com/uclouvain/openjpeg/issues/201)
|
||||
- undefined reference to `opj\_version' [\#200](https://github.com/uclouvain/openjpeg/issues/200)
|
||||
- In tgt.c we used fprintf not the openjpeg message reporter [\#184](https://github.com/uclouvain/openjpeg/issues/184)
|
||||
- Windows binaries not working under WinXP [\#176](https://github.com/uclouvain/openjpeg/issues/176)
|
||||
- add ability to use intel ipp \(performance primitive\) within OpenJPEG [\#164](https://github.com/uclouvain/openjpeg/issues/164)
|
||||
- Migration guide v2 [\#160](https://github.com/uclouvain/openjpeg/issues/160)
|
||||
- Cannot decompress JPEG2000Aware3.18.7.3Win32\_kdutranscode6.3.1.j2k [\#158](https://github.com/uclouvain/openjpeg/issues/158)
|
||||
- Cannot decompress JPEG2000Aware3.18.7.3Win32.j2k [\#157](https://github.com/uclouvain/openjpeg/issues/157)
|
||||
- openjpeg@googlegroups.com has disappeard [\#153](https://github.com/uclouvain/openjpeg/issues/153)
|
||||
- OpenJPEG 1.5.0 crashes on a ridiculously big file... [\#151](https://github.com/uclouvain/openjpeg/issues/151)
|
||||
- opj\_image vs free [\#146](https://github.com/uclouvain/openjpeg/issues/146)
|
||||
- Windows .dll file invalid [\#140](https://github.com/uclouvain/openjpeg/issues/140)
|
||||
- Problem with second layer of a 2 layer coded LRCP \(with precincts\) [\#135](https://github.com/uclouvain/openjpeg/issues/135)
|
||||
- version 1.4 crashes when opening PDF file with JPEG2000 images [\#133](https://github.com/uclouvain/openjpeg/issues/133)
|
||||
- Setup a win64 dashboard [\#132](https://github.com/uclouvain/openjpeg/issues/132)
|
||||
- J2KP4files/codestreams\_profile0/p0\_13.j2k question jpeg2000 [\#131](https://github.com/uclouvain/openjpeg/issues/131)
|
||||
- Out of memory: Kill process 11204 \(opj\_server\) score 917 or sacrifice child [\#123](https://github.com/uclouvain/openjpeg/issues/123)
|
||||
- FILE\* in opj API is unsafe [\#120](https://github.com/uclouvain/openjpeg/issues/120)
|
||||
- third-party lib order [\#119](https://github.com/uclouvain/openjpeg/issues/119)
|
||||
- openjpeg-1.5.0-Darwin-powerpc.dmg is huge ! [\#113](https://github.com/uclouvain/openjpeg/issues/113)
|
||||
- misleading info in JP2 box lead to wrong number of components [\#110](https://github.com/uclouvain/openjpeg/issues/110)
|
||||
- Image\_to\_j2k says that j2k files is generated but no file is on the HDD [\#109](https://github.com/uclouvain/openjpeg/issues/109)
|
||||
- Error in openjpegV1.4 on compiling image\_to\_j2k: crash on reading bmp file [\#108](https://github.com/uclouvain/openjpeg/issues/108)
|
||||
- Update to abi-compliance-checker 1.96 [\#106](https://github.com/uclouvain/openjpeg/issues/106)
|
||||
- Decode error on the attached JPEG...works in KDU and with JASPER...please help! [\#101](https://github.com/uclouvain/openjpeg/issues/101)
|
||||
- Mac binaries v1.4 is broken [\#95](https://github.com/uclouvain/openjpeg/issues/95)
|
||||
- jp2\_read\_boxhdr\(\) has size bug in version 1 [\#92](https://github.com/uclouvain/openjpeg/issues/92)
|
||||
- Support for Java JAI Imageio [\#90](https://github.com/uclouvain/openjpeg/issues/90)
|
||||
- encoding test failing [\#86](https://github.com/uclouvain/openjpeg/issues/86)
|
||||
- source archive on demand [\#85](https://github.com/uclouvain/openjpeg/issues/85)
|
||||
- CMakeLists.txt and Makefile.am for JPIP are buggy [\#84](https://github.com/uclouvain/openjpeg/issues/84)
|
||||
- pclr-cmap-cdef [\#82](https://github.com/uclouvain/openjpeg/issues/82)
|
||||
- Error when compiling openjpeg\_v1\_4\_sources\_r697 [\#79](https://github.com/uclouvain/openjpeg/issues/79)
|
||||
- J2K codec issue on Windows Mobile [\#77](https://github.com/uclouvain/openjpeg/issues/77)
|
||||
- image\_to\_j2k.exe crashes on large .bmp file [\#75](https://github.com/uclouvain/openjpeg/issues/75)
|
||||
- fatal error C1900 building the project on windows [\#65](https://github.com/uclouvain/openjpeg/issues/65)
|
||||
- same option but different size [\#54](https://github.com/uclouvain/openjpeg/issues/54)
|
||||
- Missing openjpegConfigure.h [\#38](https://github.com/uclouvain/openjpeg/issues/38)
|
||||
- Not an issue in openjpeg, but ... [\#37](https://github.com/uclouvain/openjpeg/issues/37)
|
||||
- OpenJPEG-1.3.0 pclr, cmap and cdef [\#27](https://github.com/uclouvain/openjpeg/issues/27)
|
||||
- realloc maybe too big \(t2.c\) [\#26](https://github.com/uclouvain/openjpeg/issues/26)
|
||||
- libopenjpeg/opj\_malloc.h breaks on FreeBSD/Darwin systems [\#20](https://github.com/uclouvain/openjpeg/issues/20)
|
||||
- image\_to\_j2k not outputting to win32 console properly [\#18](https://github.com/uclouvain/openjpeg/issues/18)
|
||||
- \[OpenJPEG\] OpenJPEG\_v13: tiled image part 2 [\#17](https://github.com/uclouvain/openjpeg/issues/17)
|
||||
- JP2 Color Space modification by Matteo Italia [\#13](https://github.com/uclouvain/openjpeg/issues/13)
|
||||
- Patch submission \( exotic video formats, and a few things \) [\#12](https://github.com/uclouvain/openjpeg/issues/12)
|
||||
- 16 bits lossy compression [\#10](https://github.com/uclouvain/openjpeg/issues/10)
|
||||
- pnm file formats not accepting bitdepth greater than 8 bpp [\#8](https://github.com/uclouvain/openjpeg/issues/8)
|
||||
- Heap corruption in j2k encoder [\#5](https://github.com/uclouvain/openjpeg/issues/5)
|
||||
- JPWL crash in marker reallocation\(+patch\), segfault while decoding image with main header protection [\#4](https://github.com/uclouvain/openjpeg/issues/4)
|
||||
- a couple of small errors in libopenjpeg detected by coverity [\#1](https://github.com/uclouvain/openjpeg/issues/1)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Shared library build broken on ubuntu [\#728](https://github.com/uclouvain/openjpeg/issues/728)
|
||||
- opj\_includes.h shouldn't define `\_\_attribute\_\_` [\#727](https://github.com/uclouvain/openjpeg/issues/727)
|
||||
- Possible website problems due to Jekyll upgrade [\#713](https://github.com/uclouvain/openjpeg/issues/713)
|
||||
- Stable Release? [\#712](https://github.com/uclouvain/openjpeg/issues/712)
|
||||
- Meta Issue : try to fix some of these critical bugs before thinking about optimizing the library [\#710](https://github.com/uclouvain/openjpeg/issues/710)
|
||||
- Tiled encoding broken for images with non power of 2 dimensions [\#702](https://github.com/uclouvain/openjpeg/issues/702)
|
||||
- install\_name \(still\) not set on OS X [\#700](https://github.com/uclouvain/openjpeg/issues/700)
|
||||
- Add section in wiki describing where one can get test images [\#699](https://github.com/uclouvain/openjpeg/issues/699)
|
||||
- Make EvenManager into singleton [\#698](https://github.com/uclouvain/openjpeg/issues/698)
|
||||
- Remove old branches from repo [\#696](https://github.com/uclouvain/openjpeg/issues/696)
|
||||
- MQ Coder encode: Conditional jump or move depends on uninitialised value\(s\) [\#695](https://github.com/uclouvain/openjpeg/issues/695)
|
||||
- Can we add these files to our test suite ? [\#688](https://github.com/uclouvain/openjpeg/issues/688)
|
||||
- -t and -d command line flags for decode are not documented on OpenJPEG website [\#685](https://github.com/uclouvain/openjpeg/issues/685)
|
||||
- Decoding at the precinct level [\#676](https://github.com/uclouvain/openjpeg/issues/676)
|
||||
- Support unscaled 10 bit data for 2K cinema @ 48 FPS, as per DCI standard [\#671](https://github.com/uclouvain/openjpeg/issues/671)
|
||||
- Use parallel jobs in ctest [\#664](https://github.com/uclouvain/openjpeg/issues/664)
|
||||
- \[Security\]Multiple Memory error [\#663](https://github.com/uclouvain/openjpeg/issues/663)
|
||||
- lossy encoding a 16 bit TIF file : severe artifiacts in decompressed image [\#660](https://github.com/uclouvain/openjpeg/issues/660)
|
||||
- opj\_compress and opj\_decompress : get\_next\_file method uses hard-coded unix path separator [\#630](https://github.com/uclouvain/openjpeg/issues/630)
|
||||
- Uninitialized variable [\#629](https://github.com/uclouvain/openjpeg/issues/629)
|
||||
- Use of enum variable for bit flags prevents compilation as C++ source [\#619](https://github.com/uclouvain/openjpeg/issues/619)
|
||||
- Serious problem with quantization during lossy encoding [\#615](https://github.com/uclouvain/openjpeg/issues/615)
|
||||
- Decompression does not work with sequential data source [\#613](https://github.com/uclouvain/openjpeg/issues/613)
|
||||
- potential overflow in opj\_tcd\_tile\_t [\#605](https://github.com/uclouvain/openjpeg/issues/605)
|
||||
- Logical condition [\#596](https://github.com/uclouvain/openjpeg/issues/596)
|
||||
- file9.jp2 does not dump correctly on 1.5 [\#595](https://github.com/uclouvain/openjpeg/issues/595)
|
||||
- opj\_compress man page is missing documentation of -jpip option [\#593](https://github.com/uclouvain/openjpeg/issues/593)
|
||||
- opj\_compress fails to compress lossless on gcc/x86 \(-m32\) in 1.5 branch [\#591](https://github.com/uclouvain/openjpeg/issues/591)
|
||||
- Example: opj\_compress -i image.j2k -o image.pgm [\#577](https://github.com/uclouvain/openjpeg/issues/577)
|
||||
- Mismatching delete [\#575](https://github.com/uclouvain/openjpeg/issues/575)
|
||||
- Compilation fails on Win7 [\#546](https://github.com/uclouvain/openjpeg/issues/546)
|
||||
- NR-JP2-file5.jp2-compare2base fails with third party libcms [\#540](https://github.com/uclouvain/openjpeg/issues/540)
|
||||
- CTest spits out an error at the end of the test run [\#516](https://github.com/uclouvain/openjpeg/issues/516)
|
||||
- opj\_uint\_adds\(\) is questionable [\#515](https://github.com/uclouvain/openjpeg/issues/515)
|
||||
- Might consider renaming this method: [\#491](https://github.com/uclouvain/openjpeg/issues/491)
|
||||
- opj\_compress run twice gives different fiile sizes for same file [\#490](https://github.com/uclouvain/openjpeg/issues/490)
|
||||
- Android Support [\#483](https://github.com/uclouvain/openjpeg/issues/483)
|
||||
- Add SSE2/SSE41 implementations for mct.c [\#451](https://github.com/uclouvain/openjpeg/issues/451)
|
||||
- Reduce encoder code block memory usage for non 64x64 code block sizes [\#444](https://github.com/uclouvain/openjpeg/issues/444)
|
||||
- valgrind "Uninitialized Memory Read" & "Uninitialized Memory Conditional" found [\#438](https://github.com/uclouvain/openjpeg/issues/438)
|
||||
- No way to debug opj\_tcd\_init\_encode\_tile or opj\_tcd\_init\_decode\_tile [\#433](https://github.com/uclouvain/openjpeg/issues/433)
|
||||
- Add option to call dsymutil on built binaries [\#409](https://github.com/uclouvain/openjpeg/issues/409)
|
||||
- Allow opj\_compress and opj\_decompress to read/write images over stdin/stdout [\#379](https://github.com/uclouvain/openjpeg/issues/379)
|
||||
- reduce memory significantly for single tile RGB encoding [\#375](https://github.com/uclouvain/openjpeg/issues/375)
|
||||
- Switch code repo to github and start using pull request workflow [\#373](https://github.com/uclouvain/openjpeg/issues/373)
|
||||
- This is a BigTIFF file. This format not supported [\#125](https://github.com/uclouvain/openjpeg/issues/125)
|
||||
- Add a test suite to check the convert functions [\#99](https://github.com/uclouvain/openjpeg/issues/99)
|
||||
- Add build config to the dashboard to verify the autotools build [\#88](https://github.com/uclouvain/openjpeg/issues/88)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Correct abi-check.sh for PR [\#791](https://github.com/uclouvain/openjpeg/pull/791) ([mayeut](https://github.com/mayeut))
|
||||
- Update tcd.c [\#790](https://github.com/uclouvain/openjpeg/pull/790) ([maddin200](https://github.com/maddin200))
|
||||
- Update lcms2 [\#773](https://github.com/uclouvain/openjpeg/pull/773) ([mayeut](https://github.com/mayeut))
|
||||
- Use lowercase for cmake commands consistenly [\#769](https://github.com/uclouvain/openjpeg/pull/769) ([julienmalik](https://github.com/julienmalik))
|
||||
- Ignore clang's summary warning [\#768](https://github.com/uclouvain/openjpeg/pull/768) ([julienmalik](https://github.com/julienmalik))
|
||||
- Fix UBSan gcc warning for first arg to memset non null [\#767](https://github.com/uclouvain/openjpeg/pull/767) ([julienmalik](https://github.com/julienmalik))
|
||||
- Update to libtiff-4.0.6 [\#764](https://github.com/uclouvain/openjpeg/pull/764) ([mayeut](https://github.com/mayeut))
|
||||
- Fix warnings [\#763](https://github.com/uclouvain/openjpeg/pull/763) ([mayeut](https://github.com/mayeut))
|
||||
- Check SSIZ is valid in opj\_j2k\_read\_siz [\#762](https://github.com/uclouvain/openjpeg/pull/762) ([mayeut](https://github.com/mayeut))
|
||||
- Fix unsigned int overflow reported by UBSan [\#761](https://github.com/uclouvain/openjpeg/pull/761) ([mayeut](https://github.com/mayeut))
|
||||
- Fix unsigned int overflow reported by UBSan [\#759](https://github.com/uclouvain/openjpeg/pull/759) ([mayeut](https://github.com/mayeut))
|
||||
- Fix negative shift left reported by UBSan [\#758](https://github.com/uclouvain/openjpeg/pull/758) ([mayeut](https://github.com/mayeut))
|
||||
- Fix negative shift left reported by UBSan [\#757](https://github.com/uclouvain/openjpeg/pull/757) ([mayeut](https://github.com/mayeut))
|
||||
- Add clang 3.9 build to Travis matrix [\#753](https://github.com/uclouvain/openjpeg/pull/753) ([julienmalik](https://github.com/julienmalik))
|
||||
- Fix implicit floating bool conversion [\#752](https://github.com/uclouvain/openjpeg/pull/752) ([julienmalik](https://github.com/julienmalik))
|
||||
- Do not define \_\_attribute\_\_ in opj\_includes.h [\#751](https://github.com/uclouvain/openjpeg/pull/751) ([mayeut](https://github.com/mayeut))
|
||||
- Allow to read/write 3/5/7/9/11/13/15 bpp TIF files [\#750](https://github.com/uclouvain/openjpeg/pull/750) ([mayeut](https://github.com/mayeut))
|
||||
- Fix heap-buffer-overflow in color\_esycc\_to\_rgb [\#748](https://github.com/uclouvain/openjpeg/pull/748) ([mayeut](https://github.com/mayeut))
|
||||
- update libpng to from 1.6.17 to 1.6.21 [\#747](https://github.com/uclouvain/openjpeg/pull/747) ([julienmalik](https://github.com/julienmalik))
|
||||
- Update cmake & jpylyzer for travis builds [\#746](https://github.com/uclouvain/openjpeg/pull/746) ([julienmalik](https://github.com/julienmalik))
|
||||
- Fix Out-Of-Bounds Read in sycc42x\_to\_rgb function [\#745](https://github.com/uclouvain/openjpeg/pull/745) ([mayeut](https://github.com/mayeut))
|
||||
- cppcheck fix for openjp2 [\#740](https://github.com/uclouvain/openjpeg/pull/740) ([julienmalik](https://github.com/julienmalik))
|
||||
- Fix uninitialized variable reported by cppcheck [\#735](https://github.com/uclouvain/openjpeg/pull/735) ([julienmalik](https://github.com/julienmalik))
|
||||
- Remove dead code in opj\_dump [\#734](https://github.com/uclouvain/openjpeg/pull/734) ([julienmalik](https://github.com/julienmalik))
|
||||
- issue \#695 MQ Encode: ensure that bp pointer never points to uninitialized memory [\#708](https://github.com/uclouvain/openjpeg/pull/708) ([boxerab](https://github.com/boxerab))
|
||||
- Fix issue 135 [\#706](https://github.com/uclouvain/openjpeg/pull/706) ([mayeut](https://github.com/mayeut))
|
||||
- Fix implementation of opj\_calloc [\#705](https://github.com/uclouvain/openjpeg/pull/705) ([stweil](https://github.com/stweil))
|
||||
- \[git/2.1 regression\] Fix opj\_write\_tile\(\) failure when numresolutions=1 [\#690](https://github.com/uclouvain/openjpeg/pull/690) ([rouault](https://github.com/rouault))
|
||||
- Fix fatal crash on 64 bit Linux [\#687](https://github.com/uclouvain/openjpeg/pull/687) ([stweil](https://github.com/stweil))
|
||||
- \[libtiff\] Add missing include statement for ssize\_t [\#686](https://github.com/uclouvain/openjpeg/pull/686) ([mayeut](https://github.com/mayeut))
|
||||
- Fix duplicate article in comments [\#684](https://github.com/uclouvain/openjpeg/pull/684) ([stweil](https://github.com/stweil))
|
||||
- Fix grammar in comment [\#679](https://github.com/uclouvain/openjpeg/pull/679) ([stweil](https://github.com/stweil))
|
||||
- Remove whitespace and CR at line endings [\#678](https://github.com/uclouvain/openjpeg/pull/678) ([stweil](https://github.com/stweil))
|
||||
- Fix typos [\#665](https://github.com/uclouvain/openjpeg/pull/665) ([jwilk](https://github.com/jwilk))
|
||||
- Add missing source for the JPIP library and executables \(issue \#658\) [\#659](https://github.com/uclouvain/openjpeg/pull/659) ([stweil](https://github.com/stweil))
|
||||
- Fix undefined size jp2 box handling [\#654](https://github.com/uclouvain/openjpeg/pull/654) ([mayeut](https://github.com/mayeut))
|
||||
- opj\_decompress: Update error message [\#651](https://github.com/uclouvain/openjpeg/pull/651) ([stweil](https://github.com/stweil))
|
||||
- Fix support of posix\_memalloc for Linux [\#648](https://github.com/uclouvain/openjpeg/pull/648) ([stweil](https://github.com/stweil))
|
||||
- Fix typo in comments [\#647](https://github.com/uclouvain/openjpeg/pull/647) ([stweil](https://github.com/stweil))
|
||||
- Avoid pointer arithmetic with \(void \*\) pointers [\#644](https://github.com/uclouvain/openjpeg/pull/644) ([smuehlst](https://github.com/smuehlst))
|
||||
- Fix HP compiler warning about redeclaration of function \(\#640\) [\#641](https://github.com/uclouvain/openjpeg/pull/641) ([smuehlst](https://github.com/smuehlst))
|
||||
- Fix format strings and unneeded assignment [\#638](https://github.com/uclouvain/openjpeg/pull/638) ([stweil](https://github.com/stweil))
|
||||
- Fix repository for JPEG2000 test data [\#637](https://github.com/uclouvain/openjpeg/pull/637) ([stweil](https://github.com/stweil))
|
||||
- Update allocation functions [\#636](https://github.com/uclouvain/openjpeg/pull/636) ([mayeut](https://github.com/mayeut))
|
||||
- Fix OpenJPEG GitHub issue \#633. [\#634](https://github.com/uclouvain/openjpeg/pull/634) ([smuehlst](https://github.com/smuehlst))
|
||||
- travis-ci: Include add ons in matrix [\#632](https://github.com/uclouvain/openjpeg/pull/632) ([mayeut](https://github.com/mayeut))
|
||||
- Add Appveyor [\#627](https://github.com/uclouvain/openjpeg/pull/627) ([mayeut](https://github.com/mayeut))
|
||||
- Use Travis-ci to run ABI check [\#626](https://github.com/uclouvain/openjpeg/pull/626) ([mayeut](https://github.com/mayeut))
|
||||
- Fix warnings for C++ [\#623](https://github.com/uclouvain/openjpeg/pull/623) ([stweil](https://github.com/stweil))
|
||||
- Fixed problem that C++ compilation failed because of enum variable. [\#622](https://github.com/uclouvain/openjpeg/pull/622) ([smuehlst](https://github.com/smuehlst))
|
||||
- Added missing casts for return values of opj\_malloc\(\)/opj\_calloc\(\). [\#618](https://github.com/uclouvain/openjpeg/pull/618) ([smuehlst](https://github.com/smuehlst))
|
||||
- Add check for seek support before trying TPsot==TNsot workaround [\#617](https://github.com/uclouvain/openjpeg/pull/617) ([mayeut](https://github.com/mayeut))
|
||||
- Fix some typos found by codespell [\#610](https://github.com/uclouvain/openjpeg/pull/610) ([stweil](https://github.com/stweil))
|
||||
- Correct leak in color\_cielab\_to\_rgb [\#590](https://github.com/uclouvain/openjpeg/pull/590) ([mayeut](https://github.com/mayeut))
|
||||
- Add Travis-ci build matrix [\#584](https://github.com/uclouvain/openjpeg/pull/584) ([mayeut](https://github.com/mayeut))
|
||||
- Correct lossless issue on linux x86 [\#579](https://github.com/uclouvain/openjpeg/pull/579) ([mayeut](https://github.com/mayeut))
|
||||
- Travis-ci update [\#578](https://github.com/uclouvain/openjpeg/pull/578) ([mayeut](https://github.com/mayeut))
|
||||
- Correct CMake version requirements [\#572](https://github.com/uclouvain/openjpeg/pull/572) ([mayeut](https://github.com/mayeut))
|
||||
- Add tests for CMYK/esYCC/CIELab [\#567](https://github.com/uclouvain/openjpeg/pull/567) ([mayeut](https://github.com/mayeut))
|
||||
- Add support for CIELab, EYCC and CMYK [\#559](https://github.com/uclouvain/openjpeg/pull/559) ([szukw000](https://github.com/szukw000))
|
||||
- Remove printf/fprintf to stdout/stderr throughout openjp2 lib [\#558](https://github.com/uclouvain/openjpeg/pull/558) ([mayeut](https://github.com/mayeut))
|
||||
- better -ffast-math handling [\#555](https://github.com/uclouvain/openjpeg/pull/555) ([rdieter](https://github.com/rdieter))
|
||||
- Add jpylyzer tests for JP2 compression [\#552](https://github.com/uclouvain/openjpeg/pull/552) ([mayeut](https://github.com/mayeut))
|
||||
- Add COC/QCC in main header when needed [\#551](https://github.com/uclouvain/openjpeg/pull/551) ([mayeut](https://github.com/mayeut))
|
||||
- Use \_\_emul under msvc x86 for fast 64 = 32 \* 32 [\#550](https://github.com/uclouvain/openjpeg/pull/550) ([mayeut](https://github.com/mayeut))
|
||||
- Update convert for PNG output [\#549](https://github.com/uclouvain/openjpeg/pull/549) ([mayeut](https://github.com/mayeut))
|
||||
- Remove some warnings when building [\#548](https://github.com/uclouvain/openjpeg/pull/548) ([mayeut](https://github.com/mayeut))
|
||||
- Switch to libpng-1.6.17 [\#547](https://github.com/uclouvain/openjpeg/pull/547) ([mayeut](https://github.com/mayeut))
|
||||
- Add some missing static keywords [\#545](https://github.com/uclouvain/openjpeg/pull/545) ([mayeut](https://github.com/mayeut))
|
||||
- Switch to libcms2 mm2/Little-CMS@0e8234e090d6aab33f90e2eb0296f30aa0705e57 [\#544](https://github.com/uclouvain/openjpeg/pull/544) ([mayeut](https://github.com/mayeut))
|
||||
- Prevent overflow when coding 16 bits images [\#543](https://github.com/uclouvain/openjpeg/pull/543) ([mayeut](https://github.com/mayeut))
|
||||
- Switch to libcms2-2.6 [\#542](https://github.com/uclouvain/openjpeg/pull/542) ([mayeut](https://github.com/mayeut))
|
||||
- Update PNG support [\#538](https://github.com/uclouvain/openjpeg/pull/538) ([mayeut](https://github.com/mayeut))
|
||||
- Various Minor fixes [\#537](https://github.com/uclouvain/openjpeg/pull/537) ([mayeut](https://github.com/mayeut))
|
||||
- Update TIFF conversion to support more bit depth. [\#535](https://github.com/uclouvain/openjpeg/pull/535) ([mayeut](https://github.com/mayeut))
|
||||
- Add checks for odd looking cmap & for cmap outside jp2h box [\#534](https://github.com/uclouvain/openjpeg/pull/534) ([mayeut](https://github.com/mayeut))
|
||||
- Refactor opj\_j2k\_read\_ppm & opj\_j2k\_read\_ppt [\#533](https://github.com/uclouvain/openjpeg/pull/533) ([mayeut](https://github.com/mayeut))
|
||||
- Add option to force component splitting in imagetopnm [\#531](https://github.com/uclouvain/openjpeg/pull/531) ([mayeut](https://github.com/mayeut))
|
||||
- fix Suspicious code in j2k.c \#517 [\#529](https://github.com/uclouvain/openjpeg/pull/529) ([renevanderark](https://github.com/renevanderark))
|
||||
- Update zlib to version 1.2.8 [\#528](https://github.com/uclouvain/openjpeg/pull/528) ([mayeut](https://github.com/mayeut))
|
||||
- Fix opj\_write\_bytes\_BE \(\#518\) [\#521](https://github.com/uclouvain/openjpeg/pull/521) ([manisandro](https://github.com/manisandro))
|
||||
- Correctly decode files with incorrect tile-part header fields \(TPsot==TNsot\) [\#514](https://github.com/uclouvain/openjpeg/pull/514) ([mayeut](https://github.com/mayeut))
|
||||
- Fixed typos [\#510](https://github.com/uclouvain/openjpeg/pull/510) ([radarhere](https://github.com/radarhere))
|
||||
- Formatted the readme file [\#507](https://github.com/uclouvain/openjpeg/pull/507) ([htmfilho](https://github.com/htmfilho))
|
||||
|
||||
## [version.2.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.1) (2014-04-29)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0.1...version.2.1)
|
||||
|
||||
## [version.2.0.1](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0.1) (2014-04-22)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.2...version.2.0.1)
|
||||
|
||||
## [version.1.5.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.2) (2014-03-28)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.2.0...version.1.5.2)
|
||||
|
||||
## [version.2.0](https://github.com/uclouvain/openjpeg/releases/tag/version.2.0) (2014-03-28)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5.1...version.2.0)
|
||||
|
||||
## [version.1.5.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5.1) (2012-09-13)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.5...version.1.5.1)
|
||||
|
||||
## [version.1.5](https://github.com/uclouvain/openjpeg/releases/tag/version.1.5) (2012-02-07)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.3...version.1.5)
|
||||
|
||||
## [version.1.3](https://github.com/uclouvain/openjpeg/releases/tag/version.1.3) (2011-07-03)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.4...version.1.3)
|
||||
|
||||
## [version.1.4](https://github.com/uclouvain/openjpeg/releases/tag/version.1.4) (2011-07-03)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.2...version.1.4)
|
||||
|
||||
## [version.1.2](https://github.com/uclouvain/openjpeg/releases/tag/version.1.2) (2007-06-04)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.1...version.1.2)
|
||||
|
||||
## [version.1.1](https://github.com/uclouvain/openjpeg/releases/tag/version.1.1) (2007-01-31)
|
||||
List of fixed issues and enhancements unavailable, see [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) or [Full Changelog](https://github.com/uclouvain/openjpeg/compare/version.1.0...version.1.1)
|
||||
|
||||
|
||||
|
||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
@ -32,7 +32,7 @@ include_regular_expression("^.*$")
|
||||
#-----------------------------------------------------------------------------
|
||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||
set(OPENJPEG_VERSION_MAJOR 2)
|
||||
set(OPENJPEG_VERSION_MINOR 1)
|
||||
set(OPENJPEG_VERSION_MINOR 2)
|
||||
set(OPENJPEG_VERSION_BUILD 0)
|
||||
set(OPENJPEG_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
@ -52,11 +52,14 @@ set(PACKAGE_VERSION
|
||||
# 2.0 | 6
|
||||
# 2.0.1 | 6
|
||||
# 2.1 | 7
|
||||
# 2.1.1 | 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,
|
||||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||
if(NOT OPENJPEG_SOVERSION)
|
||||
SET(OPENJPEG_SOVERSION 7)
|
||||
set(OPENJPEG_SOVERSION 7)
|
||||
endif(NOT OPENJPEG_SOVERSION)
|
||||
set(OPENJPEG_LIBRARY_PROPERTIES
|
||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||
@ -66,7 +69,7 @@ set(OPENJPEG_LIBRARY_PROPERTIES
|
||||
# --------------------------------------------------------------------------
|
||||
# Path to additional CMake modules
|
||||
set(CMAKE_MODULE_PATH
|
||||
${CMAKE_SOURCE_DIR}/cmake
|
||||
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake
|
||||
${CMAKE_MODULE_PATH})
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@ -162,8 +165,8 @@ TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup file for setting custom ctest vars
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake.in
|
||||
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
||||
${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/CTestCustom.cmake.in
|
||||
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/CTestCustom.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
@ -190,7 +193,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# For all builds, make sure openjpeg is std99 compliant:
|
||||
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||
SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
set(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -225,7 +228,7 @@ CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
include(TestLargeFiles)
|
||||
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
||||
|
||||
# Allocating Aligned Memory Blocks
|
||||
# Allocating Aligned Memory Blocks
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
|
||||
include(CheckSymbolExists)
|
||||
@ -248,6 +251,7 @@ if(BUILD_JPIP_SERVER)
|
||||
endif()
|
||||
endif()
|
||||
add_subdirectory(src/lib)
|
||||
option(BUILD_LUTS_GENERATOR "Build utility to generate t1_luts.h" OFF)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build Applications
|
||||
@ -281,7 +285,7 @@ configure_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
|
||||
@ -321,8 +325,8 @@ endif()
|
||||
#-----------------------------------------------------------------------------
|
||||
# install all targets referenced as OPENJPEGTargets
|
||||
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||
configure_file( ${OPENJPEG_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
||||
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
configure_file( ${${OPENJPEG_NAMESPACE}_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
||||
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
@ONLY
|
||||
)
|
||||
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
|
69
INSTALL
69
INSTALL
@ -1,69 +0,0 @@
|
||||
|
||||
How to build and install openjpeg binaries
|
||||
==========================================
|
||||
|
||||
UNIX/LINUX/MacOSX/Windows systems
|
||||
--------------------------
|
||||
|
||||
Using cmake (see www.cmake.org)
|
||||
|
||||
Type:
|
||||
cmake .
|
||||
make
|
||||
|
||||
If you are root:
|
||||
make install
|
||||
|
||||
else if you have sudo power:
|
||||
sudo make install
|
||||
|
||||
else
|
||||
DESTDIR=$HOME/local make install
|
||||
|
||||
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||
(A 'html' directory is generated in the 'doc' directory)
|
||||
make doc
|
||||
|
||||
Binaries are located in the 'bin' directory.
|
||||
|
||||
Main available cmake flags:
|
||||
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path', or use DESTDIR env variable (see above)
|
||||
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
||||
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
||||
* To build the documentation: '-DBUILD_DOC:bool=on' (default: 'OFF')
|
||||
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
||||
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
||||
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
||||
** To build the JPIP server: '-DBUILD_JPIP_SERVER:bool=on' (default: 'OFF')
|
||||
* To build the JP3D library and utilities: '-DBUILD_JP3D:bool=on' (default: 'OFF') (experimental)
|
||||
* To build the Java binding: '-DBUILD_JAVA:bool=on' (default: 'OFF') (experimental).
|
||||
** to choose which java implementation, you can set your JAVA_HOME env var.
|
||||
* To build the wxWidgets/C++ viewer: 'BUILD_VIEWER:BOOL=ON' (default OFF) (experimental)
|
||||
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory'
|
||||
make
|
||||
make Experimental
|
||||
Note : JPEG2000 test files are available with 'git clone https://github.com/uclouvain/openjpeg-data.git'.
|
||||
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
||||
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
||||
been checked out of course).
|
||||
|
||||
MACOSX
|
||||
------
|
||||
|
||||
The same building procedures as above work for MACOSX.
|
||||
The xcode project file can also be used.
|
||||
|
||||
If it does not work, try adding the following flag to the cmake command :
|
||||
'-DCMAKE_OSX_ARCHITECTURES:STRING=i386'
|
||||
|
||||
WINDOWS
|
||||
-------
|
||||
|
||||
You can use cmake to generate project files for the IDE you are using (VS2010, NMake, etc).
|
||||
Type 'cmake --help' for available generators on your platform.
|
||||
|
||||
Make sure to build the third party libs (png, zlib ...):
|
||||
|
||||
'-DBUILD_THIRDPARTY:BOOL=ON'
|
75
INSTALL.md
Normal file
75
INSTALL.md
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
# OpenJPEG installation
|
||||
|
||||
The build method maintained by OpenJPEG is [CMake](https://cmake.org/).
|
||||
|
||||
## UNIX/LINUX - MacOS (terminal) - WINDOWS (cygwin, MinGW)
|
||||
|
||||
To build the library, type from source tree directory:
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
Binaries are then located in the 'bin' directory.
|
||||
|
||||
To install the library, type with root privileges:
|
||||
```
|
||||
make install
|
||||
make clean
|
||||
```
|
||||
|
||||
To build the html documentation, you need doxygen to be installed on your system.
|
||||
It will create an "html" directory in TOP\_LEVEL/build/doc)
|
||||
```
|
||||
make doc
|
||||
```
|
||||
|
||||
Main available cmake flags:
|
||||
* To specify the install path: '-DCMAKE\_INSTALL\_PREFIX=/path'
|
||||
* To build the shared libraries and links the executables against it: '-DBUILD\_SHARED\_LIBS:bool=on' (default: 'ON')
|
||||
> Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||
* To build the CODEC executables: '-DBUILD\_CODEC:bool=on' (default: 'ON')
|
||||
* [OBSOLETE] To build the MJ2 executables: '-DBUILD\_MJ2:bool=on' (default: 'OFF')
|
||||
* [OBSOLETE] To build the JPWL executables and JPWL library: '-DBUILD\_JPWL:bool=on' (default: 'OFF')
|
||||
* [OBSOLETE] To build the JPIP client (java compiler recommended) library and executables: '-DBUILD\_JPIP:bool=on' (default: 'OFF')
|
||||
* [OBSOLETE] To build the JPIP server (need fcgi) library and executables: '-DBUILD\_JPIP\_SERVER:bool=on' (default: 'OFF')
|
||||
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||
```
|
||||
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory' -DBUILDNAME:STRING='name_of_the_build'
|
||||
make
|
||||
make Experimental
|
||||
```
|
||||
Note : test data is available on the following github repo: https://github.com/uclouvain/openjpeg-data
|
||||
|
||||
If '-DOPJ\_DATA\_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE\_SOURCE\_DIR}/../data'.
|
||||
|
||||
Note 2 : to execute the encoding test suite, kakadu binaries are needed to decode encoded image and compare it to the baseline. Kakadu binaries are freely available for non-commercial purposes at http://www.kakadusoftware.com. kdu\_expand will need to be in your PATH for cmake to find it.
|
||||
|
||||
Note 3 : OpenJPEG encoder and decoder (not the library itself !) depends on several libraries: png, tiff, lcms, z. If these libraries are not found on the system, they are automatically built from the versions available in the source tree. You can force the use of these embedded version with BUILD\_THIRDPARTY:BOOL=ON. On a Debian-like system you can also simply install these libraries with:
|
||||
```
|
||||
sudo apt-get install liblcms2-dev libtiff-dev libpng-dev libz-dev
|
||||
```
|
||||
|
||||
Note 4 : On MacOS, if it does not work, try adding the following flag to the cmake command :
|
||||
```
|
||||
-DCMAKE_OSX_ARCHITECTURES:STRING=i386
|
||||
```
|
||||
|
||||
## MacOS (XCode) - WINDOWS (VisualStudio, etc)
|
||||
|
||||
You can use cmake to generate the project files for the IDE you are using (VC2010, XCode, etc).
|
||||
Type 'cmake --help' for available generators on your platform.
|
||||
|
||||
# Using OpenJPEG
|
||||
|
||||
To use openjpeg exported cmake file, simply create your application doing:
|
||||
|
||||
```
|
||||
$ cat CMakeLists.txt
|
||||
find_package(OpenJPEG REQUIRED)
|
||||
include_directories(${OPENJPEG_INCLUDE_DIRS})
|
||||
add_executable(myapp myapp.c)
|
||||
target_link_libraries(myapp ${OPENJPEG_LIBRARIES})
|
||||
```
|
61
NEWS
61
NEWS
@ -1,61 +0,0 @@
|
||||
|
||||
OpenJPEG NEWS - user visible changes
|
||||
====================================
|
||||
|
||||
Changes from OpenJPEG 2.0.0 to OpenJPEG 2.X.X
|
||||
----------------------------------------------
|
||||
|
||||
New Features:
|
||||
|
||||
* Digital Cinema profiles have been fixed and updated
|
||||
* New option to disable MCT if needed
|
||||
* extended RAW support: it is now possible to input raw images
|
||||
with subsampled color components (422, 420, etc)
|
||||
* New way to deal with profiles
|
||||
|
||||
API/ABI modifications: (see abi_compat_report in dev-utils/scripts)
|
||||
|
||||
* Removed deprecated functions
|
||||
- opj_stream_create_default_file_stream(FILE*,...)
|
||||
- opj_stream_create_file_stream(FILE*,...)
|
||||
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
|
||||
* Added
|
||||
- opj_stream_create_default_file_stream(char*,...)
|
||||
- opj_stream_create_file_stream(char*,...)
|
||||
- opj_stream_destroy(opj_stream_t*)
|
||||
- opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
|
||||
... opj_stream_free_user_data_fn p_function)
|
||||
- JPEG 2000 profiles and Part-2 extensions defined through '#define'
|
||||
* Changed
|
||||
- 'alpha' field added to 'opj_image_comp' structure
|
||||
- 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
|
||||
- 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
|
||||
- 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
|
||||
(not yet used in use)
|
||||
- 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
|
||||
|
||||
Misc:
|
||||
|
||||
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
|
||||
and will soon become official reference software at the
|
||||
JPEG committee.
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
||||
|
||||
|
||||
Changes from OpenJPEG 1.5.x to OpenJPEG 2.0.0
|
||||
----------------------------------------------
|
||||
|
||||
New Features:
|
||||
|
||||
* streaming capabilities
|
||||
* merge JP3D
|
||||
|
||||
API modifications:
|
||||
|
||||
* Use a 64bits capable API
|
||||
|
||||
Misc:
|
||||
|
||||
* removed autotools build system
|
||||
* folders hierarchies reorganisation
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
72
NEWS.md
Normal file
72
NEWS.md
Normal file
@ -0,0 +1,72 @@
|
||||
# OpenJPEG NEWS
|
||||
|
||||
More details in the [Changelog](https://github.com/uclouvain/openjpeg/blob/master/CHANGELOG.md)
|
||||
|
||||
## OpenJPEG 2.1.2
|
||||
|
||||
* Bug fixes (including security fixes)
|
||||
* No API/ABI break compared to v2.1.1
|
||||
|
||||
## OpenJPEG 2.1.1
|
||||
|
||||
* Huge amount of critical bugfixes
|
||||
* Speed improvements
|
||||
* No API/ABI break compared to v2.1
|
||||
|
||||
## OpenJPEG 2.1.0
|
||||
|
||||
### New Features
|
||||
|
||||
* Digital Cinema profiles have been fixed and updated
|
||||
* New option to disable MCT if needed
|
||||
* extended RAW support: it is now possible to input raw images
|
||||
with subsampled color components (422, 420, etc)
|
||||
* New way to deal with profiles
|
||||
|
||||
### API/ABI modifications
|
||||
(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
|
||||
|
||||
* Removed deprecated functions
|
||||
* opj_stream_create_default_file_stream(FILE*,...)
|
||||
* opj_stream_create_file_stream(FILE*,...)
|
||||
* opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)
|
||||
* Added
|
||||
* opj_stream_create_default_file_stream(char*,...)
|
||||
* opj_stream_create_file_stream(char*,...)
|
||||
* opj_stream_destroy(opj_stream_t*)
|
||||
* opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data,
|
||||
... opj_stream_free_user_data_fn p_function)
|
||||
* JPEG 2000 profiles and Part-2 extensions defined through '#define'
|
||||
* Changed
|
||||
* 'alpha' field added to 'opj_image_comp' structure
|
||||
* 'OPJ_CLRSPC_EYCC' added to enum COLOR_SPACE
|
||||
* 'OPJ_CLRSPC_CMYK' added to enum COLOR_SPACE
|
||||
* 'OPJ_CODEC_JPP' and 'OPJ_CODEC_JPX' added to CODEC_FORMAT
|
||||
(not yet used in use)
|
||||
* 'max_cs_size' and 'rsiz' fields added to opj_cparameters_t
|
||||
|
||||
### Misc
|
||||
|
||||
* OpenJPEG is now officially conformant with JPEG 2000 Part-1
|
||||
and will soon become official reference software at the
|
||||
JPEG committee.
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
||||
|
||||
|
||||
## OpenJPEG 2.0.0
|
||||
|
||||
### New Features
|
||||
|
||||
* streaming capabilities
|
||||
* merge JP3D
|
||||
|
||||
### API modifications
|
||||
(see [here](http://www.openjpeg.org/abi-check/timeline/openjpeg/) for details)
|
||||
|
||||
* Use a 64bits capable API
|
||||
|
||||
### Misc
|
||||
|
||||
* removed autotools build system
|
||||
* folders hierarchies reorganisation
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
@ -1,7 +1,7 @@
|
||||
|
||||
# OPENJPEG Library and Applications
|
||||
|
||||
## What is OpenJPEG ?
|
||||
## What is OpenJPEG ?
|
||||
|
||||
OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of [JPEG 2000](http://www.jpeg.org/jpeg2000), a still-image compression standard from the Joint Photographic Experts Group ([JPEG](http://www.jpeg.org)). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a [JPEG 2000 Reference Software](http://www.itu.int/rec/T-REC-T.804-201504-I!Amd2).
|
||||
|
||||
@ -52,12 +52,14 @@ The library is developed and maintained by the Image and Signal Processing Group
|
||||
|
||||
See [LICENSE][link-license] for license and copyright information.
|
||||
|
||||
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL) for installation procedures.
|
||||
See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md) for installation procedures.
|
||||
|
||||
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS) for user visible changes in successive releases.
|
||||
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) for user visible changes in successive releases.
|
||||
|
||||
## API/ABI
|
||||
|
||||
An API/ABI timeline is automatically updated [here][link-api-timeline].
|
||||
|
||||
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
|
||||
only exposes a limited subset of its functions. It uses a mechanism of
|
||||
exporting/hiding functions. If you are unsure which functions you can use in
|
||||
@ -77,3 +79,4 @@ API available is the one supported by OpenJPEG.
|
||||
[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"
|
||||
[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"
|
||||
|
35
THANKS
35
THANKS
@ -1,35 +0,0 @@
|
||||
OpenJPEG THANKS file
|
||||
|
||||
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
|
||||
or submitting actual code. Here is a list of these people. Help me keep
|
||||
it complete and exempt of errors.
|
||||
|
||||
Giuseppe Baruffa
|
||||
Ben Boeckel
|
||||
Aaron Boxer
|
||||
David Burken
|
||||
Matthieu Darbois
|
||||
Rex Dieter
|
||||
Herve Drolon
|
||||
Antonin Descampe
|
||||
Francois-Olivier Devaux
|
||||
Parvatha Elangovan
|
||||
Jerôme Fimes
|
||||
Bob Friesenhahn
|
||||
Kaori Hagihara
|
||||
Luc Hermitte
|
||||
Luis Ibanez
|
||||
David Janssens
|
||||
Hans Johnson
|
||||
Callum Lerwick
|
||||
Sebastien Lugan
|
||||
Benoit Macq
|
||||
Arnaud Maye
|
||||
Julien Malik
|
||||
Vincent Nicolas
|
||||
Glenn Pearson
|
||||
Dzonatas Sol
|
||||
Winfried Szukalski
|
||||
Vincent Torri
|
||||
Yannick Verschueren
|
||||
Peter Wimmer
|
39
THANKS.md
Normal file
39
THANKS.md
Normal file
@ -0,0 +1,39 @@
|
||||
# OpenJPEG THANKS file
|
||||
|
||||
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
|
||||
or submitting actual code. Here is a list of these people. Help me keep
|
||||
it complete and exempt of errors.
|
||||
|
||||
* Giuseppe Baruffa
|
||||
* Ben Boeckel
|
||||
* Aaron Boxer
|
||||
* David Burken
|
||||
* Matthieu Darbois
|
||||
* Rex Dieter
|
||||
* Herve Drolon
|
||||
* Antonin Descampe
|
||||
* Francois-Olivier Devaux
|
||||
* Parvatha Elangovan
|
||||
* Jerôme Fimes
|
||||
* Bob Friesenhahn
|
||||
* Kaori Hagihara
|
||||
* Luc Hermitte
|
||||
* Luis Ibanez
|
||||
* David Janssens
|
||||
* Hans Johnson
|
||||
* Callum Lerwick
|
||||
* Ke Liu (Tencent's Xuanwu LAB)
|
||||
* Sebastien Lugan
|
||||
* Benoit Macq
|
||||
* Mathieu Malaterre
|
||||
* Julien Malik
|
||||
* Arnaud Maye
|
||||
* Vincent Nicolas
|
||||
* Aleksander Nikolic (Cisco Talos)
|
||||
* Glenn Pearson
|
||||
* Even Rouault
|
||||
* Dzonatas Sol
|
||||
* Winfried Szukalski
|
||||
* Vincent Torri
|
||||
* Yannick Verschueren
|
||||
* Peter Wimmer
|
19
appveyor.yml
19
appveyor.yml
@ -2,14 +2,16 @@ version: 2.1.1.{build}
|
||||
branches:
|
||||
except:
|
||||
- coverity_scan
|
||||
skip_tags: true
|
||||
skip_tags: false
|
||||
clone_depth: 50
|
||||
environment:
|
||||
matrix:
|
||||
- OPJ_CI_ARCH: x86
|
||||
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||
OPJ_CI_INCLUDE_IF_DEPLOY: 1
|
||||
- OPJ_CI_ARCH: x64
|
||||
OPJ_CI_VSCOMNTOOLS: $(VS140COMNTOOLS)
|
||||
OPJ_CI_INCLUDE_IF_DEPLOY: 1
|
||||
- OPJ_CI_ARCH: x86
|
||||
OPJ_CI_VSCOMNTOOLS: $(VS100COMNTOOLS)
|
||||
install:
|
||||
@ -20,4 +22,17 @@ build_script:
|
||||
|
||||
bash ./tools/travis-ci/run.sh
|
||||
test: off
|
||||
deploy: off
|
||||
#before_deploy:
|
||||
#- cmd: c:\cygwin\bin\bash ./tools/travis-ci/before_deploy.sh
|
||||
deploy:
|
||||
#release: openjpeg-$(appveyor_repo_tag_name)
|
||||
description: 'OpenJPEG $(appveyor_repo_tag_name) has been released. More info [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/NEWS) and a detailed view [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/CHANGES).'
|
||||
provider: GitHub
|
||||
auth_token:
|
||||
secure: Huk03f1heCD/HMyA+4ZeVmICdmKn9rPxK5p8/KxzgL+FtJDHlqcllcCrtN9bDxRH # your encrypted token from GitHub
|
||||
artifact: /.*\.zip/ # upload all zip packages to release assets
|
||||
draft: false
|
||||
prerelease: false
|
||||
on:
|
||||
appveyor_repo_tag: true # deploy on tag push only
|
||||
OPJ_CI_INCLUDE_IF_DEPLOY: 1
|
||||
|
@ -25,6 +25,9 @@ set(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||
set(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||
|
||||
# Ignore clang's summary warning, assuming prior text has matched some
|
||||
# other warning expression:
|
||||
"[0-9,]+ warnings? generated."
|
||||
# Suppress warning caused by intentional messages about deprecation
|
||||
".*warning,.* is deprecated"
|
||||
# java also warns about deprecated API
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Ensure that an include file is provided by the system
|
||||
# Add the check about the mandatory status to the check_include_file macro
|
||||
# Add the check about the mandatory status to the check_include_file macro
|
||||
# provided by cmake
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
@ -23,4 +23,4 @@ if (NOT ${${VARIABLE_NAME}})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
endmacro()
|
||||
|
@ -145,7 +145,7 @@ HTML_STYLESHEET =
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = NO
|
||||
HTML_TIMESTAMP = NO
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
GENERATE_DOCSET = NO
|
||||
|
@ -32,7 +32,7 @@
|
||||
.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
opj_compress -
|
||||
opj_compress \-
|
||||
This program reads in an image of a certain type and converts it to a
|
||||
jpeg2000 file. It is part of the OpenJPEG library.
|
||||
.SP
|
||||
@ -43,20 +43,20 @@ Valid output image extensions are
|
||||
.B .j2k, .jp2
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B opj_compress -i \fRinfile.bmp \fB-o \fRoutfile.j2k
|
||||
.B opj_compress \-i \fRinfile.bmp \fB-o \fRoutfile.j2k
|
||||
.P
|
||||
.B opj_compress -ImgDir \fRdirectory_name \fB-OutFor \fRjp2
|
||||
.B opj_compress \-ImgDir \fRdirectory_name \fB-OutFor \fRjp2
|
||||
.P
|
||||
.B opj_compress -h \fRPrint a help message and exit.
|
||||
.B opj_compress \-h \fRPrint a help message and exit.
|
||||
.P
|
||||
.R See JPWL OPTIONS for special options
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\^b " n,n"
|
||||
(Size of code block (e.g. -b 32,32). Default: 64 x 64)
|
||||
(Size of code block (e.g. \-b 32,32). Default: 64 x 64)
|
||||
.TP
|
||||
.B \-\^c " n"
|
||||
(Size of precinct (e.g. -c 128,128). Default: 2^15 x 2^15)
|
||||
(Size of precinct (e.g. \-c 128,128). Default: 2^15 x 2^15)
|
||||
.TP
|
||||
.B \-\^cinema2K " fps"
|
||||
Digital Cinema 2K profile compliant codestream. Valid \fBfps\fR values are 24 or 48.
|
||||
@ -65,7 +65,7 @@ Digital Cinema 2K profile compliant codestream. Valid \fBfps\fR values are 24 or
|
||||
Digital Cinema 4K profile compliant codestream. Does not need an fps: default is 24 fps.
|
||||
.TP
|
||||
.B \-\^d " X,Y"
|
||||
(Offset of image origin (e.g. -d 150,300))
|
||||
(Offset of image origin (e.g. \-d 150,300))
|
||||
.TP
|
||||
.B \-\^h
|
||||
Print a help message and exit.
|
||||
@ -85,20 +85,20 @@ Progression order. \fBname\fR can be one out of:LRCP, RLCP, RPCL, PCRL, CPRL. De
|
||||
.B \-\^q " n"
|
||||
different psnr for successive layers
|
||||
.br
|
||||
.B Note: \fR(options -r and -q cannot be used together)
|
||||
.B Note: \fR(options \-r and \-q cannot be used together)
|
||||
.TP
|
||||
.B \-\^r " n"
|
||||
different compression ratio(s) for successive layers. The rate specified for each quality level is the desired compression factor.
|
||||
.br
|
||||
.B Note: \fR(options -r and -q cannot be used together)
|
||||
.B Note: \fR(options \-r and \-q cannot be used together)
|
||||
.TP
|
||||
.B \-\^s " X,Y"
|
||||
sub-sampling factor (e.g. -s 2,2). Default: No sub-sampling in x or y direction.
|
||||
sub-sampling factor (e.g. \-s 2,2). Default: No sub-sampling in x or y direction.
|
||||
.br
|
||||
.B Remark: \fRsub-sampling bigger than 2 can produce errors.
|
||||
.TP
|
||||
.B \-\^t " W,H"
|
||||
(Size of tile (e.g. -t 512,512) )
|
||||
(Size of tile (e.g. \-t 512,512) )
|
||||
.TP
|
||||
.B \-\^x " name"
|
||||
(Create index file and fill it. Default: no index file)
|
||||
@ -132,7 +132,7 @@ ERTERM(16)
|
||||
.br
|
||||
SEGMARK(32)
|
||||
.br
|
||||
Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38
|
||||
Values can be added: RESTART(4) + RESET(2) + SEGMARK(32) = \-M 38
|
||||
.TP
|
||||
.B \-\^OutFor "ext"
|
||||
(extension for output files)
|
||||
@ -149,7 +149,7 @@ e.g. \fB-ROI c=0,U=25\fR
|
||||
(Write SOP marker before each packet. Default: No SOP marker in the codestream.)
|
||||
.TP
|
||||
.B \-\^T "X,Y"
|
||||
(Offset of the origin of the tiles (e.g. -T 100,75) )
|
||||
(Offset of the origin of the tiles (e.g. \-T 100,75) )
|
||||
.TP
|
||||
.B \-\^W
|
||||
(see JPWL OPTIONS)
|
||||
@ -157,7 +157,7 @@ e.g. \fB-ROI c=0,U=25\fR
|
||||
.SH JPWL OPTIONS
|
||||
Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||
.P
|
||||
.B -W h<tilepart><=type>, s<tilepart><=method>, a=<addr>, z=<size>, g=<range>, p<tilepart:pack><=type>
|
||||
.B \-W h<tilepart><=type>, s<tilepart><=method>, a=<addr>, z=<size>, g=<range>, p<tilepart:pack><=type>
|
||||
.P
|
||||
.B h\fR selects the header error protection (EPB): \fBtype\fR can be
|
||||
[0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]
|
||||
@ -176,7 +176,7 @@ Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||
(max. 16 specs)
|
||||
.P
|
||||
.B s \fRenables sensitivity data insertion (ESD): \fBmethod\fR can be
|
||||
[-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
|
||||
[\-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR
|
||||
4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]
|
||||
if \fBtilepart\fR is absent, it is for main header only
|
||||
if \fBtilepart\fR is present, it applies from that tile
|
||||
@ -194,13 +194,13 @@ Options usable only if the library has been compiled with \fB-DUSE_JPWL\fR
|
||||
.P
|
||||
.SH EXAMPLES
|
||||
.P
|
||||
.B opj_compress -i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
|
||||
.B opj_compress \-i \fRfile.bmp \fB-o \fRfile.j2k \fB-r \fR20,10,1 (compress 20x, then 10x, then lossless).
|
||||
.P
|
||||
.B opj_compress -i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
|
||||
.B opj_compress \-i \fRfile.ppm \fB-o \fRfile.j2k \fB-q \fR30,40,50
|
||||
.P
|
||||
.B opj_compress -i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
|
||||
.B opj_compress \-i \fRfile.pgx \fB-o \fRfile.j2k \fB-POC \fRT1=0,0,1,5,3,CPRL
|
||||
.P
|
||||
.B opj_compress -i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
|
||||
.B opj_compress \-i \fRlena.raw \fB-o \fRlena.j2k \fB-F \fR512,512,3,8,u
|
||||
.P
|
||||
.SH AUTHORS
|
||||
Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
|
@ -32,7 +32,7 @@
|
||||
.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
opj_decompress -
|
||||
opj_decompress \-
|
||||
This program reads in a jpeg2000 image and converts it to another
|
||||
image type. It is part of the OpenJPEG library.
|
||||
.SP
|
||||
@ -43,11 +43,11 @@ Valid output image extensions are
|
||||
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B opj_decompress -i \fRinfile.j2k \fB-o \fRoutfile.png
|
||||
.B opj_decompress \-i \fRinfile.j2k \fB-o \fRoutfile.png
|
||||
.P
|
||||
.B opj_decompress -ImgDir \fRimages/ \fB-OutFor \fRbmp
|
||||
.B opj_decompress \-ImgDir \fRimages/ \fB-OutFor \fRbmp
|
||||
.P
|
||||
.B opj_decompress -h \fRPrint help message and exit
|
||||
.B opj_decompress \-h \fRPrint help message and exit
|
||||
.P
|
||||
.R See JPWL OPTIONS for special options
|
||||
.SH OPTIONS
|
||||
|
@ -32,7 +32,7 @@
|
||||
.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files"
|
||||
.P
|
||||
.SH NAME
|
||||
opj_dump -
|
||||
opj_dump \-
|
||||
This program reads in a jpeg2000 image and dumps the contents to stdout. It is part of the OpenJPEG library.
|
||||
.SP
|
||||
Valid input image extensions are
|
||||
@ -40,11 +40,11 @@ Valid input image extensions are
|
||||
.SP
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
.B opj_dump -i \fRinfile.j2k
|
||||
.B opj_dump \-i \fRinfile.j2k
|
||||
.P
|
||||
.B opj_dump -ImgDir \fRimages/ \fRDump all files in images/
|
||||
.B opj_dump \-ImgDir \fRimages/ \fRDump all files in images/
|
||||
.P
|
||||
.B opj_dump -h \fRPrint help message and exit
|
||||
.B opj_dump \-h \fRPrint help message and exit
|
||||
.P
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
|
@ -1,7 +1,7 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# opj_apps_config.h generation
|
||||
# opj_apps_config.h generation
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_apps_config.h.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_apps_config.h
|
||||
@ONLY
|
||||
)
|
||||
)
|
||||
|
@ -91,22 +91,24 @@ static void sycc444_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max, i;
|
||||
size_t maxw, maxh, max, i;
|
||||
int offset, upb;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
maxw = (size_t)img->comps[0].w; maxh = (size_t)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
if(r == NULL || g == NULL || b == NULL) goto fails;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
@ -116,91 +118,138 @@ static void sycc444_to_rgb(opj_image_t *img)
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
free(r);
|
||||
free(g);
|
||||
free(b);
|
||||
}/* sycc444_to_rgb() */
|
||||
|
||||
static void sycc422_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max;
|
||||
size_t maxw, maxh, max, offx, loopmaxw;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
size_t i;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
maxw = (size_t)img->comps[0].w; maxh = (size_t)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
if(r == NULL || g == NULL || b == NULL) goto fails;
|
||||
|
||||
/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
|
||||
offx = img->x0 & 1U;
|
||||
loopmaxw = maxw - offx;
|
||||
|
||||
for(i=0U; i < maxh; ++i)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
size_t j;
|
||||
|
||||
if (offx > 0U) {
|
||||
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
}
|
||||
|
||||
for(j=0U; j < (loopmaxw & ~(size_t)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if (j < maxw) {
|
||||
if (j < loopmaxw) {
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
#if defined(USE_JPWL) || defined(USE_MJ2)
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
#else
|
||||
img->comps[1].w = (OPJ_UINT32)maxw; img->comps[1].h = (OPJ_UINT32)maxh;
|
||||
img->comps[2].w = (OPJ_UINT32)maxw; img->comps[2].h = (OPJ_UINT32)maxh;
|
||||
#endif
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
img->comps[1].w = img->comps[2].w = img->comps[0].w;
|
||||
img->comps[1].h = img->comps[2].h = img->comps[0].h;
|
||||
img->comps[1].dx = img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[2].dy = img->comps[0].dy;
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
free(r);
|
||||
free(g);
|
||||
free(b);
|
||||
}/* sycc422_to_rgb() */
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||
const int *y, *cb, *cr, *ny;
|
||||
unsigned int maxw, maxh, max;
|
||||
size_t maxw, maxh, max, offx, loopmaxw, offy, loopmaxh;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
size_t i;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
maxw = (size_t)img->comps[0].w; maxh = (size_t)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
if (r == NULL || g == NULL || b == NULL) goto fails;
|
||||
|
||||
/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
|
||||
offx = img->x0 & 1U;
|
||||
loopmaxw = maxw - offx;
|
||||
/* if img->y0 is odd, then first line shall use Cb/Cr = 0 */
|
||||
offy = img->y0 & 1U;
|
||||
loopmaxh = maxh - offy;
|
||||
|
||||
if (offy > 0U) {
|
||||
size_t j;
|
||||
|
||||
for(j=0; j < maxw; ++j)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U)
|
||||
for(i=0U; i < (loopmaxh & ~(size_t)1U); i += 2U)
|
||||
{
|
||||
size_t j;
|
||||
|
||||
ny = y + maxw;
|
||||
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||
|
||||
if (offx > 0U) {
|
||||
sycc_to_rgb(offset, upb, *y, 0, 0, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
}
|
||||
|
||||
for(j=0; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
for(j=0; j < (loopmaxw & ~(size_t)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
@ -212,7 +261,7 @@ static void sycc420_to_rgb(opj_image_t *img)
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
if(j < loopmaxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
@ -222,9 +271,11 @@ static void sycc420_to_rgb(opj_image_t *img)
|
||||
}
|
||||
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||
}
|
||||
if(i < maxh)
|
||||
if(i < loopmaxh)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
size_t j;
|
||||
|
||||
for(j=0U; j < (maxw & ~(size_t)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
@ -244,18 +295,17 @@ static void sycc420_to_rgb(opj_image_t *img)
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
#if defined(USE_JPWL) || defined(USE_MJ2)
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
#else
|
||||
img->comps[1].w = (OPJ_UINT32)maxw; img->comps[1].h = (OPJ_UINT32)maxh;
|
||||
img->comps[2].w = (OPJ_UINT32)maxw; img->comps[2].h = (OPJ_UINT32)maxh;
|
||||
#endif
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
img->comps[1].w = img->comps[2].w = img->comps[0].w;
|
||||
img->comps[1].h = img->comps[2].h = img->comps[0].h;
|
||||
img->comps[1].dx = img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[2].dy = img->comps[0].dy;
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
free(r);
|
||||
free(g);
|
||||
free(b);
|
||||
}/* sycc420_to_rgb() */
|
||||
|
||||
void color_sycc_to_rgb(opj_image_t *img)
|
||||
@ -300,8 +350,6 @@ void color_sycc_to_rgb(opj_image_t *img)
|
||||
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
img->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
}/* color_sycc_to_rgb() */
|
||||
|
||||
#if defined(OPJ_HAVE_LIBLCMS2) || defined(OPJ_HAVE_LIBLCMS1)
|
||||
@ -328,17 +376,17 @@ void color_apply_icc_profile(opj_image_t *image)
|
||||
cmsHPROFILE in_prof, out_prof;
|
||||
cmsHTRANSFORM transform;
|
||||
cmsColorSpaceSignature in_space, out_space;
|
||||
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||
cmsUInt32Number intent, in_type, out_type;
|
||||
int *r, *g, *b;
|
||||
int prec, i, max, max_w, max_h;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
size_t nr_samples, i, max, max_w, max_h;
|
||||
int prec, ok = 0;
|
||||
OPJ_COLOR_SPACE new_space;
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
in_prof = cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
#ifdef DEBUG_PROFILE
|
||||
FILE *icm = fopen("debug.icm","wb");
|
||||
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
|
||||
fclose(icm);
|
||||
FILE *icm = fopen("debug.icm","wb");
|
||||
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
|
||||
fclose(icm);
|
||||
#endif
|
||||
|
||||
if(in_prof == NULL) return;
|
||||
@ -348,80 +396,83 @@ void color_apply_icc_profile(opj_image_t *image)
|
||||
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||
|
||||
|
||||
max_w = (int)image->comps[0].w;
|
||||
max_h = (int)image->comps[0].h;
|
||||
max_w = image->comps[0].w;
|
||||
max_h = image->comps[0].h;
|
||||
prec = (int)image->comps[0].prec;
|
||||
oldspace = image->color_space;
|
||||
|
||||
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
in_type = TYPE_RGB_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
}
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
in_type = TYPE_RGB_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||
__FILE__,__LINE__,out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||
__FILE__,__LINE__,out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
cmsCloseProfile(in_prof);
|
||||
|
||||
return;
|
||||
}
|
||||
if(out_prof == NULL)
|
||||
{
|
||||
cmsCloseProfile(in_prof);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||
|
||||
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||
" type: in(%u) out:(%u)\n",
|
||||
intent,
|
||||
in_space,
|
||||
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||
(in_space>>8) & 0xff, in_space & 0xff,
|
||||
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||
" type: in(%u) out:(%u)\n",
|
||||
intent,
|
||||
in_space,
|
||||
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||
(in_space>>8) & 0xff, in_space & 0xff,
|
||||
|
||||
out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff,
|
||||
out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff,
|
||||
|
||||
in_type,out_type
|
||||
);
|
||||
in_type,out_type
|
||||
);
|
||||
#else
|
||||
(void)prec;
|
||||
(void)in_space;
|
||||
#endif /* DEBUG_PROFILE */
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type,
|
||||
out_prof, out_type, intent, 0);
|
||||
transform = cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||
@ -430,129 +481,217 @@ fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
#endif
|
||||
|
||||
if(transform == NULL)
|
||||
{
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
#endif
|
||||
image->color_space = oldspace;
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(image->numcomps > 2)/* RGB, RGBA */
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (size_t)(max * 3U * sizeof(unsigned char));
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
*in++ = (unsigned char)*g++;
|
||||
*in++ = (unsigned char)*b++;
|
||||
}
|
||||
if(inbuf == NULL || outbuf == NULL) goto fails0;
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
*in++ = (unsigned char)*g++;
|
||||
*in++ = (unsigned char)*b++;
|
||||
}
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
fails0:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
else /* prec > 8 */
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (size_t)(max * 3U * sizeof(unsigned short));
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
}
|
||||
else /* GRAY, GRAYA */
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
if(inbuf == NULL || outbuf == NULL) goto fails1;
|
||||
|
||||
image->comps = (opj_image_comp_t*)
|
||||
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
for(i = 0U ; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
image->comps[1].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
image->numcomps += 2;
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
r = image->comps[0].data;
|
||||
fails1:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
}
|
||||
else /* image->numcomps <= 2 : GRAY, GRAYA */
|
||||
{
|
||||
if(prec <= 8)
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
opj_image_comp_t *new_comps;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
max = max_w * max_h;
|
||||
nr_samples = (size_t)(max * 3 * sizeof(unsigned char));
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
g = (int*)calloc((size_t)max, sizeof(int));
|
||||
b = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
if(inbuf == NULL || outbuf == NULL || g == NULL || b == NULL) goto fails2;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
new_comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
}/* if(image->numcomps */
|
||||
if(new_comps == NULL) goto fails2;
|
||||
|
||||
image->comps = new_comps;
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = g;
|
||||
image->comps[2].data = b;
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
r = g = b = NULL;
|
||||
ok = 1;
|
||||
|
||||
fails2:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
free(g);
|
||||
free(b);
|
||||
}
|
||||
else /* prec > 8 */
|
||||
{
|
||||
unsigned short *in, *inbuf, *out, *outbuf;
|
||||
opj_image_comp_t *new_comps;
|
||||
|
||||
max = max_w * max_h;
|
||||
nr_samples = (size_t)(max * 3U * sizeof(unsigned short));
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
g = (int*)calloc((size_t)max, sizeof(int));
|
||||
b = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL || g == NULL || b == NULL) goto fails3;
|
||||
|
||||
new_comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(new_comps == NULL) goto fails3;
|
||||
|
||||
image->comps = new_comps;
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = g;
|
||||
image->comps[2].data = b;
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
r = g = b = NULL;
|
||||
ok = 1;
|
||||
|
||||
fails3:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
free(g);
|
||||
free(b);
|
||||
}
|
||||
}/* if(image->numcomps > 2) */
|
||||
|
||||
cmsDeleteTransform(transform);
|
||||
|
||||
@ -560,15 +699,18 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
if(ok)
|
||||
{
|
||||
image->color_space = new_space;
|
||||
}
|
||||
}/* color_apply_icc_profile() */
|
||||
|
||||
void color_cielab_to_rgb(opj_image_t *image)
|
||||
{
|
||||
int *row;
|
||||
int enumcs, numcomps;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
OPJ_COLOR_SPACE new_space;
|
||||
|
||||
numcomps = (int)image->numcomps;
|
||||
|
||||
if(numcomps != 3)
|
||||
@ -595,8 +737,14 @@ void color_cielab_to_rgb(opj_image_t *image)
|
||||
cmsCIELab Lab;
|
||||
|
||||
in = cmsCreateLab4Profile(NULL);
|
||||
if(in == NULL){
|
||||
return;
|
||||
}
|
||||
out = cmsCreate_sRGBProfile();
|
||||
|
||||
if(out == NULL){
|
||||
cmsCloseProfile(in);
|
||||
return;
|
||||
}
|
||||
transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
@ -611,6 +759,8 @@ void color_cielab_to_rgb(opj_image_t *image)
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
new_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
prec0 = (double)image->comps[0].prec;
|
||||
prec1 = (double)image->comps[1].prec;
|
||||
prec2 = (double)image->comps[2].prec;
|
||||
@ -639,7 +789,9 @@ void color_cielab_to_rgb(opj_image_t *image)
|
||||
red = dst0 = (int*)malloc(max * sizeof(int));
|
||||
green = dst1 = (int*)malloc(max * sizeof(int));
|
||||
blue = dst2 = (int*)malloc(max * sizeof(int));
|
||||
|
||||
|
||||
if(red == NULL || green == NULL || blue == NULL) goto fails;
|
||||
|
||||
minL = -(rl * ol)/(pow(2, prec0)-1);
|
||||
maxL = minL + rl;
|
||||
|
||||
@ -670,16 +822,27 @@ void color_cielab_to_rgb(opj_image_t *image)
|
||||
free(src1); image->comps[1].data = dst1;
|
||||
free(src2); image->comps[2].data = dst2;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
image->color_space = new_space;
|
||||
image->comps[0].prec = 16;
|
||||
image->comps[1].prec = 16;
|
||||
image->comps[2].prec = 16;
|
||||
|
||||
return;
|
||||
|
||||
fails:
|
||||
cmsDeleteTransform(transform);
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
if(red) free(red);
|
||||
if(green) free(green);
|
||||
if(blue) free(blue);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__,__LINE__, enumcs);
|
||||
}/* color_apply_conversion() */
|
||||
}/* color_cielab_to_rgb() */
|
||||
|
||||
#endif /* OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1 */
|
||||
|
||||
@ -692,7 +855,14 @@ void color_cmyk_to_rgb(opj_image_t *image)
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
|
||||
if(image->numcomps < 4) return;
|
||||
if (
|
||||
(image->numcomps < 4)
|
||||
|| (image->comps[0].dx != image->comps[1].dx) || (image->comps[0].dx != image->comps[2].dx) || (image->comps[0].dx != image->comps[3].dx)
|
||||
|| (image->comps[0].dy != image->comps[1].dy) || (image->comps[0].dy != image->comps[2].dy) || (image->comps[0].dy != image->comps[3].dy)
|
||||
) {
|
||||
fprintf(stderr,"%s:%d:color_cmyk_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
max = w * h;
|
||||
|
||||
@ -744,7 +914,14 @@ void color_esycc_to_rgb(opj_image_t *image)
|
||||
int flip_value = (1 << (image->comps[0].prec-1));
|
||||
int max_value = (1 << image->comps[0].prec) - 1;
|
||||
|
||||
if(image->numcomps < 3) return;
|
||||
if (
|
||||
(image->numcomps < 3)
|
||||
|| (image->comps[0].dx != image->comps[1].dx) || (image->comps[0].dx != image->comps[2].dx)
|
||||
|| (image->comps[0].dy != image->comps[1].dy) || (image->comps[0].dy != image->comps[2].dy)
|
||||
) {
|
||||
fprintf(stderr,"%s:%d:color_esycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
|
@ -13,7 +13,7 @@ set(common_SRCS
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h
|
||||
)
|
||||
|
||||
|
||||
if(OPJ_HAVE_LIBTIFF)
|
||||
list(APPEND common_SRCS converttif.c)
|
||||
endif()
|
||||
@ -57,6 +57,9 @@ foreach(exe opj_decompress opj_compress opj_dump)
|
||||
# On unix you need to link to the math library:
|
||||
if(UNIX)
|
||||
target_link_libraries(${exe} m)
|
||||
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
target_link_libraries(${exe} rt)
|
||||
endif()
|
||||
endif()
|
||||
# Install exe
|
||||
install(TARGETS ${exe}
|
||||
@ -64,7 +67,7 @@ foreach(exe opj_decompress opj_compress opj_dump)
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
if(OPJ_USE_DSYMUTIL)
|
||||
add_custom_command(TARGET ${exe} POST_BUILD
|
||||
add_custom_command(TARGET ${exe} POST_BUILD
|
||||
COMMAND "dsymutil" "$<TARGET_FILE:${exe}>"
|
||||
COMMENT "dsymutil $<TARGET_FILE:${exe}>"
|
||||
DEPENDS ${exe})
|
||||
|
@ -611,6 +611,10 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
||||
if (id_len)
|
||||
{
|
||||
unsigned char *id = (unsigned char *) malloc(id_len);
|
||||
if(id == 0){
|
||||
fprintf(stderr, "tga_readheader: memory out\n");
|
||||
return 0;
|
||||
}
|
||||
if ( !fread(id, id_len, 1, fp) )
|
||||
{
|
||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||
@ -1249,6 +1253,7 @@ int imagetopgx(opj_image_t * image, const char *outfile)
|
||||
{
|
||||
name = (char*)malloc(total+1);
|
||||
if (name == NULL) {
|
||||
fprintf(stderr, "imagetopgx: memory out\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
@ -1323,11 +1328,14 @@ struct pnm_header
|
||||
|
||||
static char *skip_white(char *s)
|
||||
{
|
||||
while(*s)
|
||||
if (s != NULL)
|
||||
{
|
||||
if(*s == '\n' || *s == '\r') return NULL;
|
||||
if(isspace(*s)) { ++s; continue; }
|
||||
return s;
|
||||
while(*s)
|
||||
{
|
||||
if(*s == '\n' || *s == '\r') return NULL;
|
||||
if(isspace(*s)) { ++s; continue; }
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -1372,7 +1380,7 @@ static char *skip_idf(char *start, char out_idf[256])
|
||||
|
||||
static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||
{
|
||||
int format, have_wh, end, ttype;
|
||||
int format, end, ttype;
|
||||
char idf[256], type[256];
|
||||
char line[256];
|
||||
|
||||
@ -1393,11 +1401,12 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||
return;
|
||||
}
|
||||
ph->format = format;
|
||||
ttype = end = have_wh = 0;
|
||||
ttype = end = 0;
|
||||
|
||||
while(fgets(line, 250, reader))
|
||||
{
|
||||
char *s;
|
||||
int allow_null = 0;
|
||||
|
||||
if(*line == '#') continue;
|
||||
|
||||
@ -1473,36 +1482,25 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||
return;
|
||||
} /* if(format == 7) */
|
||||
|
||||
if( !have_wh)
|
||||
{
|
||||
/* Here format is in range [1,6] */
|
||||
if (ph->width == 0) {
|
||||
s = skip_int(s, &ph->width);
|
||||
|
||||
if ((s == NULL) || (*s == 0) || (ph->width < 1)) return;
|
||||
allow_null = 1;
|
||||
}
|
||||
if (ph->height == 0) {
|
||||
s = skip_int(s, &ph->height);
|
||||
|
||||
have_wh = 1;
|
||||
|
||||
if(format == 1 || format == 4) break;
|
||||
|
||||
if(format == 2 || format == 3 || format == 5 || format == 6)
|
||||
{
|
||||
if (skip_int(s, &ph->maxval) != NULL) {
|
||||
if(ph->maxval > 65535) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((s == NULL) && allow_null) continue;
|
||||
if ((s == NULL) || (*s == 0) || (ph->height < 1)) return;
|
||||
if(format == 1 || format == 4) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(format == 2 || format == 3 || format == 5 || format == 6)
|
||||
{
|
||||
/* P2, P3, P5, P6: */
|
||||
s = skip_int(s, &ph->maxval);
|
||||
|
||||
if(ph->maxval > 65535) return;
|
||||
allow_null = 1;
|
||||
}
|
||||
/* here, format is in P2, P3, P5, P6 */
|
||||
s = skip_int(s, &ph->maxval);
|
||||
if ((s == NULL) && allow_null) continue;
|
||||
if ((s == NULL) || (*s == 0)) return;
|
||||
break;
|
||||
}/* while(fgets( ) */
|
||||
if(format == 2 || format == 3 || format > 4)
|
||||
@ -1519,18 +1517,14 @@ static void read_pnm_header(FILE *reader, struct pnm_header *ph)
|
||||
}
|
||||
if(ph->depth < 1 || ph->depth > 4) return;
|
||||
|
||||
if(ph->width && ph->height && ph->depth && ph->maxval && ttype)
|
||||
if (ttype)
|
||||
ph->ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(format != 1 && format != 4)
|
||||
ph->ok = 1;
|
||||
if(format == 1 || format == 4)
|
||||
{
|
||||
if(ph->width && ph->height && ph->maxval) ph->ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ph->width && ph->height) ph->ok = 1;
|
||||
ph->maxval = 255;
|
||||
}
|
||||
}
|
||||
@ -1757,7 +1751,7 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
|
||||
const char *tmp = outfile;
|
||||
char *destname;
|
||||
|
||||
alpha = NULL;
|
||||
alpha = NULL;
|
||||
|
||||
if((prec = (int)image->comps[0].prec) > 16)
|
||||
{
|
||||
@ -1837,7 +1831,7 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
|
||||
if(two)
|
||||
{
|
||||
v = *red + adjustR; ++red;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
|
||||
/* netpbm: */
|
||||
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
|
||||
@ -1845,13 +1839,13 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(triple)
|
||||
{
|
||||
v = *green + adjustG; ++green;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
|
||||
/* netpbm: */
|
||||
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
|
||||
|
||||
v = *blue + adjustB; ++blue;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
|
||||
/* netpbm: */
|
||||
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
|
||||
@ -1861,7 +1855,7 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(has_alpha)
|
||||
{
|
||||
v = *alpha + adjustA; ++alpha;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
|
||||
/* netpbm: */
|
||||
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
|
||||
@ -1871,28 +1865,28 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
} /* if(two) */
|
||||
|
||||
/* prec <= 8: */
|
||||
v = *red++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
v = *red++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
if(triple)
|
||||
{
|
||||
v = *green++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
{
|
||||
v = *green++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
v = *blue++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
v = *blue++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
}
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
}
|
||||
if(has_alpha)
|
||||
{
|
||||
v = *alpha++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
{
|
||||
v = *alpha++;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
}
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
}
|
||||
} /* for(i */
|
||||
|
||||
fclose(fdest); return 0;
|
||||
@ -1906,18 +1900,21 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
fprintf(stderr," is written to the file\n");
|
||||
}
|
||||
destname = (char*)malloc(strlen(outfile) + 8);
|
||||
|
||||
if(destname == NULL){
|
||||
fprintf(stderr, "imagetopnm: memory out\n");
|
||||
return 1;
|
||||
}
|
||||
for (compno = 0; compno < ncomp; compno++)
|
||||
{
|
||||
if (ncomp > 1)
|
||||
{
|
||||
/*sprintf(destname, "%d.%s", compno, outfile);*/
|
||||
const size_t olen = strlen(outfile);
|
||||
const size_t dotpos = olen - 4;
|
||||
if (ncomp > 1)
|
||||
{
|
||||
/*sprintf(destname, "%d.%s", compno, outfile);*/
|
||||
const size_t olen = strlen(outfile);
|
||||
const size_t dotpos = olen - 4;
|
||||
|
||||
strncpy(destname, outfile, dotpos);
|
||||
sprintf(destname+dotpos, "_%u.pgm", compno);
|
||||
}
|
||||
strncpy(destname, outfile, dotpos);
|
||||
sprintf(destname+dotpos, "_%u.pgm", compno);
|
||||
}
|
||||
else
|
||||
sprintf(destname, "%s", outfile);
|
||||
|
||||
@ -1944,7 +1941,7 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
for (i = 0; i < wr * hr; i++)
|
||||
{
|
||||
v = *red + adjustR; ++red;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
|
||||
/* netpbm: */
|
||||
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
|
||||
@ -1952,7 +1949,7 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(has_alpha)
|
||||
{
|
||||
v = *alpha++;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
|
||||
/* netpbm: */
|
||||
fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
|
||||
@ -1963,10 +1960,10 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
|
||||
{
|
||||
for(i = 0; i < wr * hr; ++i)
|
||||
{
|
||||
v = *red + adjustR; ++red;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
v = *red + adjustR; ++red;
|
||||
if(v > 255) v = 255; else if(v < 0) v = 0;
|
||||
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
fprintf(fdest, "%c", (unsigned char)v);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
|
@ -181,7 +181,7 @@ static void bmpmask32toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_imag
|
||||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
OPJ_BOOL hasAlpha = OPJ_FALSE;
|
||||
OPJ_BOOL hasAlpha;
|
||||
OPJ_UINT32 redShift, redPrec;
|
||||
OPJ_UINT32 greenShift, greenPrec;
|
||||
OPJ_UINT32 blueShift, bluePrec;
|
||||
@ -239,7 +239,7 @@ static void bmpmask16toimage(const OPJ_UINT8* pData, OPJ_UINT32 stride, opj_imag
|
||||
OPJ_UINT32 width, height;
|
||||
OPJ_UINT32 x, y;
|
||||
const OPJ_UINT8 *pSrc = NULL;
|
||||
OPJ_BOOL hasAlpha = OPJ_FALSE;
|
||||
OPJ_BOOL hasAlpha;
|
||||
OPJ_UINT32 redShift, redPrec;
|
||||
OPJ_UINT32 greenShift, greenPrec;
|
||||
OPJ_UINT32 blueShift, bluePrec;
|
||||
@ -675,10 +675,28 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
}
|
||||
}
|
||||
|
||||
if (Info_h.biWidth == 0 || Info_h.biHeight == 0) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Info_h.biBitCount > (((OPJ_UINT32)-1) - 31) / Info_h.biWidth) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
stride = ((Info_h.biWidth * Info_h.biBitCount + 31U) / 32U) * 4U; /* rows are aligned on 32bits */
|
||||
if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /* RLE 4 gets decoded as 8 bits data for now... */
|
||||
if (8 > (((OPJ_UINT32)-1) - 31) / Info_h.biWidth) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
stride = ((Info_h.biWidth * 8U + 31U) / 32U) * 4U;
|
||||
}
|
||||
|
||||
if (stride > ((OPJ_UINT32)-1) / sizeof(OPJ_UINT8) / Info_h.biHeight) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
pData = (OPJ_UINT8 *) calloc(1, stride * Info_h.biHeight * sizeof(OPJ_UINT8));
|
||||
if (pData == NULL) {
|
||||
fclose(IN);
|
||||
@ -891,7 +909,7 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
|
||||
fprintf(fdest, "%c%c%c", bc, gc, rc);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
for (pad = ((3 * w) % 4) ? (4 - (3 * w) % 4) : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
@ -967,7 +985,7 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
|
||||
fprintf(fdest, "%c", (OPJ_UINT8)r);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
for (pad = (w % 4) ? (4 - w % 4) : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +185,17 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
||||
|
||||
|
||||
rows = (OPJ_BYTE**)calloc(height+1, sizeof(OPJ_BYTE*));
|
||||
for(i = 0; i < height; ++i)
|
||||
if(rows == NULL){
|
||||
fprintf(stderr, "pngtoimage: memory out\n");
|
||||
goto fin;
|
||||
}
|
||||
for(i = 0; i < height; ++i){
|
||||
rows[i] = (OPJ_BYTE*)malloc(png_get_rowbytes(png,info));
|
||||
|
||||
if(rows[i] == NULL){
|
||||
fprintf(stderr,"pngtoimage: memory out\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
png_read_image(png, rows);
|
||||
|
||||
/* Create image */
|
||||
@ -235,7 +243,7 @@ fin:
|
||||
if(rows)
|
||||
{
|
||||
for(i = 0; i < height; ++i)
|
||||
free(rows[i]);
|
||||
if(rows[i]) free(rows[i]);
|
||||
free(rows);
|
||||
}
|
||||
if (row32s) {
|
||||
|
@ -56,6 +56,229 @@
|
||||
TIFF IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
#define PUTBITS2(s, nb) \
|
||||
trailing <<= remaining; \
|
||||
trailing |= (unsigned int)((s) >> (nb - remaining)); \
|
||||
*pDst++ = (OPJ_BYTE)trailing; \
|
||||
trailing = (unsigned int)((s) & ((1U << (nb - remaining)) - 1U)); \
|
||||
if (nb >= (remaining + 8)) { \
|
||||
*pDst++ = (OPJ_BYTE)(trailing >> (nb - (remaining + 8))); \
|
||||
trailing &= (unsigned int)((1U << (nb - (remaining + 8))) - 1U); \
|
||||
remaining += 16 - nb; \
|
||||
} else { \
|
||||
remaining += 8 - nb; \
|
||||
}
|
||||
|
||||
#define PUTBITS(s, nb) \
|
||||
if (nb >= remaining) { \
|
||||
PUTBITS2(s, nb) \
|
||||
} else { \
|
||||
trailing <<= nb; \
|
||||
trailing |= (unsigned int)(s); \
|
||||
remaining -= nb; \
|
||||
}
|
||||
#define FLUSHBITS() \
|
||||
if (remaining != 8) { \
|
||||
trailing <<= remaining; \
|
||||
*pDst++ = (OPJ_BYTE)trailing; \
|
||||
}
|
||||
|
||||
static void tif_32sto3u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 5) | (src1 << 2) | (src2 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 7) | (src3 << 4) | (src4 << 1) | (src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 << 3) | (src7));
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 3)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 3)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 3)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 3)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 3)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 3)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto5u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 3) | (src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 << 1) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 7) | (src5 << 2) | (src6 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 5) | (src7));
|
||||
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 5)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 5)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 5)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 5)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 5)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 5)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto7u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 1) | (src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 3) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 5) | (src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 7) | (src7));
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+0], 7)
|
||||
if (length > 1U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+1], 7)
|
||||
if (length > 2U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+2], 7)
|
||||
if (length > 3U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+3], 7)
|
||||
if (length > 4U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+4], 7)
|
||||
if (length > 5U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+5], 7)
|
||||
if (length > 6U) {
|
||||
PUTBITS((OPJ_UINT32)pSrc[i+6], 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto9u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 7) | (src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 5) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 3) | (src5 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 2) | (src6 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 1) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 9)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 9)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 9)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 9)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 9)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 9)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
|
||||
static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
@ -95,6 +318,59 @@ static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto11u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 5) | (src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src2 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 7) | (src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 1) | (src5 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 3) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 11)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 11)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 11)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 11)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 11)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 11)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 11)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -113,6 +389,61 @@ static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
||||
*pDst++ = (OPJ_BYTE)(((src0 & 0xFU) << 4));
|
||||
}
|
||||
}
|
||||
static void tif_32sto13u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 3) | (src1 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src1 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 6) | (src2 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 1) | (src3 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)((src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src4 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 7) | (src5 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 2) | (src6 >> 11));
|
||||
*pDst++ = (OPJ_BYTE)((src6 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 5) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 13)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 13)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 13)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 13)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 13)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 13)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -155,6 +486,63 @@ static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto15u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
|
||||
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
|
||||
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
|
||||
OPJ_UINT32 src3 = (OPJ_UINT32)pSrc[i+3];
|
||||
OPJ_UINT32 src4 = (OPJ_UINT32)pSrc[i+4];
|
||||
OPJ_UINT32 src5 = (OPJ_UINT32)pSrc[i+5];
|
||||
OPJ_UINT32 src6 = (OPJ_UINT32)pSrc[i+6];
|
||||
OPJ_UINT32 src7 = (OPJ_UINT32)pSrc[i+7];
|
||||
|
||||
*pDst++ = (OPJ_BYTE)((src0 >> 7));
|
||||
*pDst++ = (OPJ_BYTE)((src0 << 1) | (src1 >> 14));
|
||||
*pDst++ = (OPJ_BYTE)((src1 >> 6));
|
||||
*pDst++ = (OPJ_BYTE)((src1 << 2) | (src2 >> 13));
|
||||
*pDst++ = (OPJ_BYTE)((src2 >> 5));
|
||||
*pDst++ = (OPJ_BYTE)((src2 << 3) | (src3 >> 12));
|
||||
*pDst++ = (OPJ_BYTE)((src3 >> 4));
|
||||
*pDst++ = (OPJ_BYTE)((src3 << 4) | (src4 >> 11));
|
||||
*pDst++ = (OPJ_BYTE)((src4 >> 3));
|
||||
*pDst++ = (OPJ_BYTE)((src4 << 5) | (src5 >> 10));
|
||||
*pDst++ = (OPJ_BYTE)((src5 >> 2));
|
||||
*pDst++ = (OPJ_BYTE)((src5 << 6) | (src6 >> 9));
|
||||
*pDst++ = (OPJ_BYTE)((src6 >> 1));
|
||||
*pDst++ = (OPJ_BYTE)((src6 << 7) | (src7 >> 8));
|
||||
*pDst++ = (OPJ_BYTE)(src7);
|
||||
}
|
||||
|
||||
if (length & 7U) {
|
||||
unsigned int trailing = 0U;
|
||||
int remaining = 8U;
|
||||
length &= 7U;
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+0], 15)
|
||||
if (length > 1U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+1], 15)
|
||||
if (length > 2U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+2], 15)
|
||||
if (length > 3U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+3], 15)
|
||||
if (length > 4U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+4], 15)
|
||||
if (length > 5U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+5], 15)
|
||||
if (length > 6U) {
|
||||
PUTBITS2((OPJ_UINT32)pSrc[i+6], 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FLUSHBITS()
|
||||
}
|
||||
}
|
||||
static void tif_32sto16u(const OPJ_INT32* pSrc, OPJ_UINT16* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -223,10 +611,10 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
|
||||
if(bps > 16) bps = 0;
|
||||
if(bps == 0)
|
||||
{
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1 to 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
@ -248,15 +636,36 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
||||
case 8:
|
||||
cvt32sToTif = convert_32sXXu_C1R_LUT[bps];
|
||||
break;
|
||||
case 3:
|
||||
cvt32sToTif = tif_32sto3u;
|
||||
break;
|
||||
case 5:
|
||||
cvt32sToTif = tif_32sto5u;
|
||||
break;
|
||||
case 7:
|
||||
cvt32sToTif = tif_32sto7u;
|
||||
break;
|
||||
case 9:
|
||||
cvt32sToTif = tif_32sto9u;
|
||||
break;
|
||||
case 10:
|
||||
cvt32sToTif = tif_32sto10u;
|
||||
break;
|
||||
case 11:
|
||||
cvt32sToTif = tif_32sto11u;
|
||||
break;
|
||||
case 12:
|
||||
cvt32sToTif = tif_32sto12u;
|
||||
break;
|
||||
case 13:
|
||||
cvt32sToTif = tif_32sto13u;
|
||||
break;
|
||||
case 14:
|
||||
cvt32sToTif = tif_32sto14u;
|
||||
break;
|
||||
case 15:
|
||||
cvt32sToTif = tif_32sto15u;
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToTif = (convert_32sXXx_C1R)tif_32sto16u;
|
||||
break;
|
||||
@ -313,6 +722,221 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
||||
return 0;
|
||||
}/* imagetotif() */
|
||||
|
||||
#define GETBITS(dest, nb) { \
|
||||
int needed = (nb); \
|
||||
unsigned int dst = 0U; \
|
||||
if (available == 0) { \
|
||||
val = *pSrc++; \
|
||||
available = 8; \
|
||||
} \
|
||||
while (needed > available) { \
|
||||
dst |= val & ((1U << available) - 1U); \
|
||||
needed -= available; \
|
||||
dst <<= needed; \
|
||||
val = *pSrc++; \
|
||||
available = 8; \
|
||||
} \
|
||||
dst |= (val >> (available - needed)) & ((1U << needed) - 1U); \
|
||||
available -= needed; \
|
||||
dest = (OPJ_INT32)dst; \
|
||||
}
|
||||
|
||||
static void tif_3uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 5));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x1FU) >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val0 & 0x3U) << 1) | (val1 >> 7));
|
||||
pDst[i+3] = (OPJ_INT32)(((val1 & 0x7FU) >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val1 & 0xFU) >> 1));
|
||||
pDst[i+5] = (OPJ_INT32)(((val1 & 0x1U) << 2) | (val2 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val2 & 0x3FU) >> 3));
|
||||
pDst[i+7] = (OPJ_INT32)(((val2 & 0x7U)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 3)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 3)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 3)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 3)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 3)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 3)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_5uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 3));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x7U) << 2) | (val1 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val1 & 0x3FU) >> 1));
|
||||
pDst[i+3] = (OPJ_INT32)(((val1 & 0x1U) << 4) | (val2 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val2 & 0xFU) << 1) | (val3 >> 7));
|
||||
pDst[i+5] = (OPJ_INT32)(((val3 & 0x7FU) >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val3 & 0x3U) << 3) | (val4 >> 5));
|
||||
pDst[i+7] = (OPJ_INT32)(((val4 & 0x1FU)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 5)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 5)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 5)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 5)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 5)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 5)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_7uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 >> 1));
|
||||
pDst[i+1] = (OPJ_INT32)(((val0 & 0x1U) << 6) | (val1 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val1 & 0x3U) << 5) | (val2 >> 3));
|
||||
pDst[i+3] = (OPJ_INT32)(((val2 & 0x7U) << 4) | (val3 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val3 & 0xFU) << 3) | (val4 >> 5));
|
||||
pDst[i+5] = (OPJ_INT32)(((val4 & 0x1FU) << 2) | (val5 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val5 & 0x3FU) << 1) | (val6 >> 7));
|
||||
pDst[i+7] = (OPJ_INT32)(((val6 & 0x7FU)));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 7)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 7)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 7)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 7)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 7)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 7)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_9uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 1) | (val1 >> 7));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x7FU) << 2) | (val2 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0x3FU) << 3) | (val3 >> 5));
|
||||
pDst[i+3] = (OPJ_INT32)(((val3 & 0x1FU) << 4) | (val4 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val4 & 0xFU) << 5) | (val5 >> 3));
|
||||
pDst[i+5] = (OPJ_INT32)(((val5 & 0x7U) << 6) | (val6 >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val6 & 0x3U) << 7) | (val7 >> 1));
|
||||
pDst[i+7] = (OPJ_INT32)(((val7 & 0x1U) << 8) | (val8));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 9)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 9)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 9)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 9)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 9)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 9)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -345,6 +969,60 @@ static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_11uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 3) | (val1 >> 5));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x1FU) << 6) | (val2 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val2 & 0x3U) << 9) | (val3 << 1) | (val4 >> 7));
|
||||
pDst[i+3] = (OPJ_INT32)(((val4 & 0x7FU) << 4) | (val5 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val5 & 0xFU) << 7) | (val6 >> 1));
|
||||
pDst[i+5] = (OPJ_INT32)(((val6 & 0x1U) << 10) | (val7 << 2) | (val8 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val8 & 0x3FU) << 5) | (val9 >> 3));
|
||||
pDst[i+7] = (OPJ_INT32)(((val9 & 0x7U) << 8) | (val10));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 11)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 11)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 11)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 11)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 11)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 11)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 11)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -362,6 +1040,62 @@ static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 4) | (val1 >> 4));
|
||||
}
|
||||
}
|
||||
static void tif_13uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
OPJ_UINT32 val11 = *pSrc++;
|
||||
OPJ_UINT32 val12 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 5) | (val1 >> 3));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x7U) << 10) | (val2 << 2) | (val3 >> 6));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0x3FU) << 7) | (val4 >> 1));
|
||||
pDst[i+3] = (OPJ_INT32)(((val4 & 0x1U) << 12) | (val5 << 4) | (val6 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val6 & 0xFU) << 9) | (val7 << 1) | (val8 >> 7));
|
||||
pDst[i+5] = (OPJ_INT32)(((val8 & 0x7FU) << 6) | (val9 >> 2));
|
||||
pDst[i+6] = (OPJ_INT32)(((val9 & 0x3U) << 11) | (val10 << 3) | (val11 >> 5));
|
||||
pDst[i+7] = (OPJ_INT32)(((val11 & 0x1FU) << 8) | (val12));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 13)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 13)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 13)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 13)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 13)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 13)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -398,6 +1132,64 @@ static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_15uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
|
||||
OPJ_UINT32 val0 = *pSrc++;
|
||||
OPJ_UINT32 val1 = *pSrc++;
|
||||
OPJ_UINT32 val2 = *pSrc++;
|
||||
OPJ_UINT32 val3 = *pSrc++;
|
||||
OPJ_UINT32 val4 = *pSrc++;
|
||||
OPJ_UINT32 val5 = *pSrc++;
|
||||
OPJ_UINT32 val6 = *pSrc++;
|
||||
OPJ_UINT32 val7 = *pSrc++;
|
||||
OPJ_UINT32 val8 = *pSrc++;
|
||||
OPJ_UINT32 val9 = *pSrc++;
|
||||
OPJ_UINT32 val10 = *pSrc++;
|
||||
OPJ_UINT32 val11 = *pSrc++;
|
||||
OPJ_UINT32 val12 = *pSrc++;
|
||||
OPJ_UINT32 val13 = *pSrc++;
|
||||
OPJ_UINT32 val14 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (OPJ_INT32)((val0 << 7) | (val1 >> 1));
|
||||
pDst[i+1] = (OPJ_INT32)(((val1 & 0x1U) << 14) | (val2 << 6) | (val3 >> 2));
|
||||
pDst[i+2] = (OPJ_INT32)(((val3 & 0x3U) << 13) | (val4 << 5) | (val5 >> 3));
|
||||
pDst[i+3] = (OPJ_INT32)(((val5 & 0x7U) << 12) | (val6 << 4) | (val7 >> 4));
|
||||
pDst[i+4] = (OPJ_INT32)(((val7 & 0xFU) << 11) | (val8 << 3) | (val9 >> 5));
|
||||
pDst[i+5] = (OPJ_INT32)(((val9 & 0x1FU) << 10) | (val10 << 2) | (val11 >> 6));
|
||||
pDst[i+6] = (OPJ_INT32)(((val11 & 0x3FU) << 9) | (val12 << 1) | (val13 >> 7));
|
||||
pDst[i+7] = (OPJ_INT32)(((val13 & 0x7FU) << 8) | (val14));
|
||||
|
||||
}
|
||||
if (length & 7U) {
|
||||
unsigned int val;
|
||||
int available = 0;
|
||||
|
||||
length = length & 7U;
|
||||
|
||||
GETBITS(pDst[i+0], 15)
|
||||
|
||||
if (length > 1U) {
|
||||
GETBITS(pDst[i+1], 15)
|
||||
if (length > 2U) {
|
||||
GETBITS(pDst[i+2], 15)
|
||||
if (length > 3U) {
|
||||
GETBITS(pDst[i+3], 15)
|
||||
if (length > 4U) {
|
||||
GETBITS(pDst[i+4], 15)
|
||||
if (length > 5U) {
|
||||
GETBITS(pDst[i+5], 15)
|
||||
if (length > 6U) {
|
||||
GETBITS(pDst[i+6], 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* seems that libtiff decodes this to machine endianness */
|
||||
static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
|
||||
@ -454,8 +1246,8 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
w= (int)tiWidth;
|
||||
h= (int)tiHeight;
|
||||
|
||||
if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
|
||||
if(tiBps > 16U) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1 to 16 bits implemented\n",tiBps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
@ -476,15 +1268,36 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
cvtTifTo32s = convert_XXu32s_C1R_LUT[tiBps];
|
||||
break;
|
||||
/* others are specific to TIFF */
|
||||
case 3:
|
||||
cvtTifTo32s = tif_3uto32s;
|
||||
break;
|
||||
case 5:
|
||||
cvtTifTo32s = tif_5uto32s;
|
||||
break;
|
||||
case 7:
|
||||
cvtTifTo32s = tif_7uto32s;
|
||||
break;
|
||||
case 9:
|
||||
cvtTifTo32s = tif_9uto32s;
|
||||
break;
|
||||
case 10:
|
||||
cvtTifTo32s = tif_10uto32s;
|
||||
break;
|
||||
case 11:
|
||||
cvtTifTo32s = tif_11uto32s;
|
||||
break;
|
||||
case 12:
|
||||
cvtTifTo32s = tif_12uto32s;
|
||||
break;
|
||||
case 13:
|
||||
cvtTifTo32s = tif_13uto32s;
|
||||
break;
|
||||
case 14:
|
||||
cvtTifTo32s = tif_14uto32s;
|
||||
break;
|
||||
case 15:
|
||||
cvtTifTo32s = tif_15uto32s;
|
||||
break;
|
||||
case 16:
|
||||
cvtTifTo32s = (convert_XXx32s_C1R)tif_16uto32s;
|
||||
break;
|
||||
|
@ -69,7 +69,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cstr_info->tile[0].distotile)
|
||||
if (cstr_info->tile[0].distotile > 0.0)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
|
@ -236,7 +236,7 @@ static void encode_help_display(void) {
|
||||
fprintf(stdout,"-I\n");
|
||||
fprintf(stdout," Use the irreversible DWT 9-7.\n");
|
||||
fprintf(stdout,"-mct <0|1|2>\n");
|
||||
fprintf(stdout," Explicitely specifies if a Multiple Component Transform has to be used.\n");
|
||||
fprintf(stdout," Explicitly specifies if a Multiple Component Transform has to be used.\n");
|
||||
fprintf(stdout," 0: no MCT ; 1: RGB->YCC conversion ; 2: custom MCT.\n");
|
||||
fprintf(stdout," If custom MCT, \"-m\" option has to be used (see hereunder).\n");
|
||||
fprintf(stdout," By default, RGB->YCC conversion is used if there are 3 components or more,\n");
|
||||
@ -647,6 +647,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
raw_cp->rawBitDepth = bitdepth;
|
||||
raw_cp->rawSigned = raw_signed;
|
||||
raw_cp->rawComps = (raw_comp_cparameters_t*) malloc(((OPJ_UINT32)(ncomp))*sizeof(raw_comp_cparameters_t));
|
||||
if(raw_cp->rawComps == NULL){
|
||||
free(substr1);
|
||||
return 1;
|
||||
}
|
||||
for (compno = 0; compno < ncomp && !wrong; compno++) {
|
||||
if (substr2 == NULL) {
|
||||
raw_cp->rawComps[compno].dx = lastdx;
|
||||
@ -725,6 +729,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
numresolution = (OPJ_UINT32)parameters->numresolution;
|
||||
matrix_width = numresolution * 3;
|
||||
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||
if(parameters->cp_matrice == NULL){
|
||||
return 1;
|
||||
}
|
||||
s = s + 2;
|
||||
|
||||
for (i = 0; i < numlayers; i++) {
|
||||
@ -995,6 +1002,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
case 'z': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(img_fol->imgdirpath == NULL){
|
||||
return 1;
|
||||
}
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
@ -1019,7 +1029,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
return 1;
|
||||
}
|
||||
fprintf(stdout,"CINEMA 2K profile activated\n"
|
||||
"Other options specified could be overriden\n");
|
||||
"Other options specified could be overridden\n");
|
||||
|
||||
}
|
||||
break;
|
||||
@ -1030,7 +1040,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
{
|
||||
parameters->rsiz = OPJ_PROFILE_CINEMA_4K;
|
||||
fprintf(stdout,"CINEMA 4K profile activated\n"
|
||||
"Other options specified could be overriden\n");
|
||||
"Other options specified could be overridden\n");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1540,6 +1550,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -1635,7 +1646,7 @@ int main(int argc, char **argv) {
|
||||
/* parse input and get user encoding parameters */
|
||||
parameters.tcp_mct = (char) 255; /* This will be set later according to the input image or the provided option */
|
||||
if(parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, &raw_cp, indexfilename, sizeof(indexfilename)) == 1) {
|
||||
return 1;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
/* Read directory if necessary */
|
||||
@ -1848,7 +1859,9 @@ int main(int argc, char **argv) {
|
||||
OPJ_BYTE *l_data;
|
||||
OPJ_UINT32 l_data_size = 512*512*3;
|
||||
l_data = (OPJ_BYTE*) calloc( 1,l_data_size);
|
||||
assert( l_data );
|
||||
if(l_data == NULL){
|
||||
goto fails;
|
||||
}
|
||||
for (i=0;i<l_nb_tiles;++i) {
|
||||
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
|
||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
|
||||
@ -1904,4 +1917,16 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fails:
|
||||
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||
if(raw_cp.rawComps) free(raw_cp.rawComps);
|
||||
if(img_fol.imgdirpath) free(img_fol.imgdirpath);
|
||||
if(dirptr){
|
||||
if(dirptr->filename_buf) free(dirptr->filename_buf);
|
||||
if(dirptr->filename) free(dirptr->filename);
|
||||
free(dirptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windirent.h"
|
||||
@ -150,6 +151,8 @@ typedef struct opj_decompress_params
|
||||
int upsample;
|
||||
/* split output components to different files */
|
||||
int split_pnm;
|
||||
/** number of threads */
|
||||
int num_threads;
|
||||
}opj_decompress_parameters;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -224,8 +227,11 @@ static void decode_help_display(void) {
|
||||
" -upsample\n"
|
||||
" Downsampled components will be upsampled to image size\n"
|
||||
" -split-pnm\n"
|
||||
" Split output components to different files when writing to PNM\n"
|
||||
"\n");
|
||||
" Split output components to different files when writing to PNM\n");
|
||||
if( opj_has_thread_support() ) {
|
||||
fprintf(stdout," -threads <num_threads>\n"
|
||||
" Number of threads to use for decoding.\n");
|
||||
}
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
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'},
|
||||
{"force-rgb", 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:"
|
||||
@ -680,6 +687,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(img_fol->imgdirpath == NULL){
|
||||
return 1;
|
||||
}
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
@ -805,6 +815,22 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
|
||||
break;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<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;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
@ -882,17 +908,22 @@ OPJ_FLOAT64 opj_clock(void) {
|
||||
/* t is the high resolution performance counter (see MSDN) */
|
||||
QueryPerformanceCounter ( & t ) ;
|
||||
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
|
||||
/* Unix or Linux: use resource usage */
|
||||
struct rusage t;
|
||||
OPJ_FLOAT64 procTime;
|
||||
/* (1) Get the rusage data structure at this moment (man getrusage) */
|
||||
getrusage(0,&t);
|
||||
/* (2) What is the elapsed time ? - CPU time = User time + System time */
|
||||
/* Unix : use resource usage */
|
||||
/* FIXME: this counts the total CPU time, instead of the user perceived time */
|
||||
struct rusage t;
|
||||
OPJ_FLOAT64 procTime;
|
||||
/* (1) Get the rusage data structure at this moment (man getrusage) */
|
||||
getrusage(0,&t);
|
||||
/* (2) What is the elapsed time ? - CPU time = User time + System time */
|
||||
/* (2a) Get the seconds */
|
||||
procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec);
|
||||
/* (2b) More precisely! Get the microseconds part ! */
|
||||
return ( procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
|
||||
procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec);
|
||||
/* (2b) More precisely! Get the microseconds part ! */
|
||||
return ( procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1200,8 +1231,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
/* Initialize reading of directory */
|
||||
@ -1210,26 +1240,30 @@ int main(int argc, char **argv)
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
if(!dirptr){
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
if(!dirptr->filename_buf){
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename){
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
@ -1254,8 +1288,7 @@ int main(int argc, char **argv)
|
||||
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
|
||||
if (!l_stream){
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
|
||||
destroy_parameters(¶meters);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
/* decode the JPEG2000 stream */
|
||||
@ -1297,21 +1330,25 @@ int main(int argc, char **argv)
|
||||
/* Setup the decoder decoding parameters using user parameters */
|
||||
if ( !opj_setup_decoder(l_codec, &(parameters.core)) ){
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to setup the decoder\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
return EXIT_FAILURE;
|
||||
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*/
|
||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to read the header\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
if (!parameters.nb_tile_to_decode) {
|
||||
@ -1319,21 +1356,19 @@ int main(int argc, char **argv)
|
||||
if (!opj_set_decode_area(l_codec, image, (OPJ_INT32)parameters.DA_x0,
|
||||
(OPJ_INT32)parameters.DA_y0, (OPJ_INT32)parameters.DA_x1, (OPJ_INT32)parameters.DA_y1)){
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to set the decoded area\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
|
||||
/* Get the decoded image */
|
||||
if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
|
||||
fprintf(stderr,"ERROR -> opj_decompress: failed to decode image!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1344,16 +1379,15 @@ int main(int argc, char **argv)
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}*/
|
||||
|
||||
if (!opj_get_decoded_tile(l_codec, l_stream, image, parameters.tile_index)) {
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to decode tile!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_image_destroy(image);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
|
||||
}
|
||||
@ -1432,9 +1466,8 @@ int main(int argc, char **argv)
|
||||
image = upsample_image_components(image);
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to upsample image components!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1456,9 +1489,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "ERROR -> opj_decompress: failed to convert to RGB image!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_codec(l_codec);
|
||||
return EXIT_FAILURE;
|
||||
failed = 1; goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1567,10 +1599,17 @@ int main(int argc, char **argv)
|
||||
|
||||
if(failed) (void)remove(parameters.outfile); /* ignore return value */
|
||||
}
|
||||
fin:
|
||||
destroy_parameters(¶meters);
|
||||
if(failed && img_fol.imgdirpath) free(img_fol.imgdirpath);
|
||||
if(dirptr){
|
||||
if(dirptr->filename) free(dirptr->filename);
|
||||
if(dirptr->filename_buf) free(dirptr->filename_buf);
|
||||
free(dirptr);
|
||||
}
|
||||
if (numDecompressedImages) {
|
||||
fprintf(stdout, "decode time: %d ms\n", (int)( (tCumulative * 1000.0) / (OPJ_FLOAT64)numDecompressedImages));
|
||||
}
|
||||
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
/*end main*/
|
||||
/*end main()*/
|
||||
|
@ -341,6 +341,9 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
if(img_fol->imgdirpath == NULL){
|
||||
return 1;
|
||||
}
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
@ -433,12 +436,6 @@ int main(int argc, char *argv[])
|
||||
img_fol_t img_fol;
|
||||
dircnt_t *dirptr = NULL;
|
||||
|
||||
#ifdef MSD
|
||||
OPJ_BOOL l_go_on = OPJ_TRUE;
|
||||
OPJ_UINT32 l_max_data_size = 1000;
|
||||
OPJ_BYTE * l_data = (OPJ_BYTE *) malloc(1000);
|
||||
#endif
|
||||
|
||||
/* Set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
@ -448,6 +445,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
if(img_fol.imgdirpath) free(img_fol.imgdirpath);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@ -457,25 +456,31 @@ int main(int argc, char *argv[])
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
if(!dirptr){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
if(!dirptr->filename_buf){
|
||||
free(dirptr);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename){
|
||||
goto fails;
|
||||
}
|
||||
|
||||
for(it_image=0;it_image<num_images;it_image++){
|
||||
dirptr->filename[it_image] = dirptr->filename_buf + it_image*OPJ_PATH_LEN;
|
||||
}
|
||||
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
goto fails;
|
||||
}
|
||||
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
@ -486,7 +491,7 @@ int main(int argc, char *argv[])
|
||||
fout = fopen(parameters.outfile,"w");
|
||||
if (!fout){
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -510,7 +515,7 @@ int main(int argc, char *argv[])
|
||||
l_stream = opj_stream_create_default_file_stream(parameters.infile,1);
|
||||
if (!l_stream){
|
||||
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
/* Read the JPEG2000 stream */
|
||||
@ -552,7 +557,7 @@ int main(int argc, char *argv[])
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
/* Read the main header of the codestream and if necessary the JP2 boxes*/
|
||||
@ -562,7 +567,7 @@ int main(int argc, char *argv[])
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(image);
|
||||
fclose(fout);
|
||||
return EXIT_FAILURE;
|
||||
goto fails;
|
||||
}
|
||||
|
||||
opj_dump_codec(l_codec, img_fol.flag, fout );
|
||||
@ -594,4 +599,12 @@ int main(int argc, char *argv[])
|
||||
fclose(fout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
fails:
|
||||
if(dirptr){
|
||||
if(dirptr->filename) free(dirptr->filename);
|
||||
if(dirptr->filename_buf) free(dirptr->filename_buf);
|
||||
free(dirptr);
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Build the demo app, small examples
|
||||
|
||||
# First thing define the common source:
|
||||
SET(common_SRCS
|
||||
set(common_SRCS
|
||||
convert.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
|
||||
)
|
||||
@ -26,15 +26,15 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
# Loop over all executables:
|
||||
FOREACH(exe opj_jp3d_compress opj_jp3d_decompress)
|
||||
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||
TARGET_LINK_LIBRARIES(${exe} openjp3d)
|
||||
foreach(exe opj_jp3d_compress opj_jp3d_decompress)
|
||||
add_executable(${exe} ${exe}.c ${common_SRCS})
|
||||
target_link_libraries(${exe} openjp3d)
|
||||
# On unix you need to link to the math library:
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(${exe} m)
|
||||
ENDIF(UNIX)
|
||||
if(UNIX)
|
||||
target_link_libraries(${exe} m)
|
||||
endif(UNIX)
|
||||
# Install exe
|
||||
INSTALL(TARGETS ${exe}
|
||||
install(TARGETS ${exe}
|
||||
EXPORT OpenJP3DTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
|
@ -60,7 +60,7 @@ endforeach()
|
||||
find_package(Java 1.5 COMPONENTS Development) # javac, jar
|
||||
|
||||
# User can override this:
|
||||
if(NOT DEFINED JAVA_SOURCE_VERSION)
|
||||
if(NOT DEFINED JAVA_SOURCE_VERSION)
|
||||
set(JAVA_SOURCE_VERSION 1.5)
|
||||
endif()
|
||||
if(NOT DEFINED JAVA_TARGET_VERSION)
|
||||
|
@ -187,10 +187,9 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
|
||||
|
||||
#ifdef OPJ_BIG_ENDIAN
|
||||
|
||||
static inline int16_t swap16(int16_t x)
|
||||
static inline uint16_t swap16(uint16_t x)
|
||||
{
|
||||
return((((u_int16_t)x & 0x00ffU) << 8) |
|
||||
(((u_int16_t)x & 0xff00U) >> 8));
|
||||
return(((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -37,11 +37,11 @@ foreach(exe
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS USE_MJ2
|
||||
)
|
||||
target_link_libraries(${exe} ${LCMS_LIBNAME} openmj2)
|
||||
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(${exe} m)
|
||||
endif()
|
||||
|
||||
|
||||
install(TARGETS ${exe}
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR})
|
||||
endforeach()
|
||||
|
@ -5,10 +5,12 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/opj_config.h
|
||||
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers)
|
||||
|
||||
include_directories(
|
||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h and opj_config_private.h
|
||||
${${OPENJPEG_NAMESPACE}_BINARY_DIR}/src/lib/openjp2 # opj_config.h and opj_config_private.h
|
||||
)
|
||||
# Defines the source code for the library
|
||||
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.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cio.c
|
||||
@ -29,6 +31,7 @@ set(OPENJPEG_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mct.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mqc_inl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
|
||||
@ -73,6 +76,11 @@ if(OPJ_DISABLE_TPSOT_FIX)
|
||||
add_definitions(-DOPJ_DISABLE_TPSOT_FIX)
|
||||
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
|
||||
if(WIN32)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
@ -110,16 +118,18 @@ install(
|
||||
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
|
||||
endif()
|
||||
|
||||
# internal utilities to generate t1_luts.h (part of the jp2 lib)
|
||||
if(BUILD_LUTS_GENERATOR)
|
||||
# internal utility to generate t1_luts.h (part of the jp2 lib)
|
||||
# no need to install:
|
||||
add_executable(t1_generate_luts t1_generate_luts.c)
|
||||
if(UNIX)
|
||||
target_link_libraries(t1_generate_luts m)
|
||||
add_executable(t1_generate_luts t1_generate_luts.c)
|
||||
if(UNIX)
|
||||
target_link_libraries(t1_generate_luts m)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Experimental option; let's how cppcheck performs
|
||||
# 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
|
||||
# output gcc formatted error/warning report
|
||||
# Another implementation detail: I could not redirect error to the error
|
||||
@ -136,9 +146,42 @@ endif()
|
||||
|
||||
if(OPJ_USE_DSYMUTIL)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME} POST_BUILD
|
||||
add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME} POST_BUILD
|
||||
COMMAND "dsymutil" "$<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
|
||||
COMMENT "dsymutil $<TARGET_SONAME_FILE:${OPENJPEG_LIBRARY_NAME}>"
|
||||
DEPENDS ${OPENJPEG_LIBRARY_NAME})
|
||||
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)
|
||||
|
@ -151,19 +151,31 @@ void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
|
||||
bio->ct = 0;
|
||||
}
|
||||
|
||||
OPJ_NOSANITIZE("unsigned-integer-overflow")
|
||||
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
|
||||
OPJ_UINT32 i;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
|
||||
assert((n > 0U) && (n <= 32U));
|
||||
for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
|
||||
opj_bio_putbit(bio, (v >> i) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
OPJ_NOSANITIZE("unsigned-integer-overflow")
|
||||
OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 v;
|
||||
v = 0;
|
||||
for (i = n - 1; i < n; i--) {
|
||||
v += opj_bio_getbit(bio) << i;
|
||||
OPJ_UINT32 v;
|
||||
|
||||
assert((n > 0U) /* && (n <= 32U)*/);
|
||||
#ifdef OPJ_UBSAN_BUILD
|
||||
/* This assert fails for some corrupted images which are gracefully rejected */
|
||||
/* Add this assert only for ubsan build. */
|
||||
/* This is the condition for overflow not to occur below which is needed because of OPJ_NOSANITIZE */
|
||||
assert(n <= 32U);
|
||||
#endif
|
||||
v = 0U;
|
||||
for (i = n - 1; i < n; i--) { /* overflow used for end-loop condition */
|
||||
v |= opj_bio_getbit(bio) << i; /* can't overflow, opj_bio_getbit returns 0 or 1 */
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@ -60,7 +60,9 @@ int opj_write_cidx( int offset, opj_stream_private_t *cio, opj_codestream_info_t
|
||||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for (i=0;i<2;i++){
|
||||
|
||||
if(i)
|
||||
|
@ -124,21 +124,21 @@ static void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_st
|
||||
/**
|
||||
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,
|
||||
void (*p_function)(OPJ_INT32 *, OPJ_INT32,OPJ_INT32,OPJ_INT32) );
|
||||
|
||||
static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i);
|
||||
static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* OPJ_RESTRICT r, OPJ_UINT32 i);
|
||||
|
||||
/* <summary> */
|
||||
/* Inverse 9-7 wavelet transform in 1-D. */
|
||||
/* </summary> */
|
||||
static void opj_v4dwt_decode(opj_v4dwt_t* restrict dwt);
|
||||
static void opj_v4dwt_decode(opj_v4dwt_t* OPJ_RESTRICT dwt);
|
||||
|
||||
static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* 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);
|
||||
|
||||
static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read);
|
||||
static void opj_v4dwt_interleave_v(opj_v4dwt_t* OPJ_RESTRICT v , OPJ_FLOAT32* OPJ_RESTRICT a , OPJ_INT32 x, OPJ_INT32 nb_elts_read);
|
||||
|
||||
#ifdef __SSE__
|
||||
static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c);
|
||||
@ -395,7 +395,7 @@ static INLINE OPJ_BOOL opj_dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void
|
||||
|
||||
OPJ_INT32 rw; /* width of the resolution level computed */
|
||||
OPJ_INT32 rh; /* height of the resolution level computed */
|
||||
OPJ_UINT32 l_data_size;
|
||||
size_t l_data_size;
|
||||
|
||||
opj_tcd_resolution_t * l_cur_res = 0;
|
||||
opj_tcd_resolution_t * l_last_res = 0;
|
||||
@ -407,8 +407,14 @@ static INLINE OPJ_BOOL opj_dwt_encode_procedure(opj_tcd_tilecomp_t * tilec,void
|
||||
l_cur_res = tilec->resolutions + l;
|
||||
l_last_res = l_cur_res - 1;
|
||||
|
||||
l_data_size = opj_dwt_max_resolution( tilec->resolutions,tilec->numresolutions) * (OPJ_UINT32)sizeof(OPJ_INT32);
|
||||
bj = (OPJ_INT32*)opj_malloc((size_t)l_data_size);
|
||||
l_data_size = opj_dwt_max_resolution( tilec->resolutions,tilec->numresolutions);
|
||||
/* overflow check */
|
||||
if (l_data_size > (SIZE_MAX / sizeof(OPJ_INT32))) {
|
||||
/* FIXME event manager error callback */
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_data_size *= sizeof(OPJ_INT32);
|
||||
bj = (OPJ_INT32*)opj_malloc(l_data_size);
|
||||
/* l_data_size is equal to 0 when numresolutions == 1 but bj is not used */
|
||||
/* in that case, so do not error out */
|
||||
if (l_data_size != 0 && ! bj) {
|
||||
@ -473,8 +479,8 @@ OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec)
|
||||
/* <summary> */
|
||||
/* Inverse 5-3 wavelet transform in 2-D. */
|
||||
/* </summary> */
|
||||
OPJ_BOOL opj_dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
|
||||
return opj_dwt_decode_tile(tilec, numres, &opj_dwt_decode_1);
|
||||
OPJ_BOOL opj_dwt_decode(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
|
||||
return opj_dwt_decode_tile(tp, tilec, numres, &opj_dwt_decode_1);
|
||||
}
|
||||
|
||||
|
||||
@ -543,7 +549,7 @@ void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) {
|
||||
/* <summary> */
|
||||
/* Determine maximum computed resolution level for inverse wavelet transform */
|
||||
/* </summary> */
|
||||
static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i) {
|
||||
static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* OPJ_RESTRICT r, OPJ_UINT32 i) {
|
||||
OPJ_UINT32 mr = 0;
|
||||
OPJ_UINT32 w;
|
||||
while( --i ) {
|
||||
@ -556,10 +562,73 @@ static OPJ_UINT32 opj_dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_U
|
||||
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> */
|
||||
/* Inverse wavelet transform in 2-D. */
|
||||
/* Inverse wavelet transform in 2-D. */
|
||||
/* </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 v;
|
||||
|
||||
@ -569,11 +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 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
|
||||
size_t h_mem_size;
|
||||
int num_threads;
|
||||
|
||||
if (numres == 1U) {
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
h.mem = (OPJ_INT32*)opj_aligned_malloc(opj_dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
|
||||
num_threads = opj_thread_pool_get_thread_count(tp);
|
||||
h_mem_size = opj_dwt_max_resolution(tr, numres);
|
||||
/* overflow check */
|
||||
if (h_mem_size > (SIZE_MAX / sizeof(OPJ_INT32))) {
|
||||
/* FIXME event manager error callback */
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
h_mem_size *= sizeof(OPJ_INT32);
|
||||
h.mem = (OPJ_INT32*)opj_aligned_malloc(h_mem_size);
|
||||
if (! h.mem){
|
||||
/* FIXME event manager error callback */
|
||||
return OPJ_FALSE;
|
||||
@ -582,7 +661,7 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres
|
||||
v.mem = h.mem;
|
||||
|
||||
while( --numres) {
|
||||
OPJ_INT32 * restrict tiledp = tilec->data;
|
||||
OPJ_INT32 * OPJ_RESTRICT tiledp = tilec->data;
|
||||
OPJ_UINT32 j;
|
||||
|
||||
++tr;
|
||||
@ -595,30 +674,134 @@ 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.cas = tr->x0 % 2;
|
||||
|
||||
for(j = 0; j < rh; ++j) {
|
||||
opj_dwt_interleave_h(&h, &tiledp[j*w]);
|
||||
(dwt_1D)(&h);
|
||||
memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
|
||||
if( num_threads <= 1 || rh <= 1 )
|
||||
{
|
||||
for(j = 0; j < rh; ++j) {
|
||||
opj_dwt_interleave_h(&h, &tiledp[j*w]);
|
||||
(dwt_1D)(&h);
|
||||
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.cas = tr->y0 % 2;
|
||||
|
||||
for(j = 0; j < rw; ++j){
|
||||
OPJ_UINT32 k;
|
||||
opj_dwt_interleave_v(&v, &tiledp[j], (OPJ_INT32)w);
|
||||
(dwt_1D)(&v);
|
||||
for(k = 0; k < rh; ++k) {
|
||||
tiledp[k * w + j] = v.mem[k];
|
||||
if( num_threads <= 1 || rw <= 1 )
|
||||
{
|
||||
for(j = 0; j < rw; ++j){
|
||||
OPJ_UINT32 k;
|
||||
|
||||
opj_dwt_interleave_v(&v, &tiledp[j], (OPJ_INT32)w);
|
||||
(dwt_1D)(&v);
|
||||
for(k = 0; k < rh; ++k) {
|
||||
tiledp[k * w + j] = v.mem[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restrict a, OPJ_INT32 x, OPJ_INT32 size){
|
||||
OPJ_FLOAT32* restrict bi = (OPJ_FLOAT32*) (w->wavelet + w->cas);
|
||||
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_INT32 count = w->sn;
|
||||
OPJ_INT32 i, k;
|
||||
|
||||
@ -660,8 +843,8 @@ static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restric
|
||||
}
|
||||
}
|
||||
|
||||
static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read){
|
||||
opj_v4_t* restrict bi = v->wavelet + v->cas;
|
||||
static void opj_v4dwt_interleave_v(opj_v4dwt_t* OPJ_RESTRICT v , OPJ_FLOAT32* OPJ_RESTRICT a , OPJ_INT32 x, OPJ_INT32 nb_elts_read){
|
||||
opj_v4_t* OPJ_RESTRICT bi = v->wavelet + v->cas;
|
||||
OPJ_INT32 i;
|
||||
|
||||
for(i = 0; i < v->sn; ++i){
|
||||
@ -679,7 +862,7 @@ static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restri
|
||||
#ifdef __SSE__
|
||||
|
||||
static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c){
|
||||
__m128* restrict vw = (__m128*) w;
|
||||
__m128* OPJ_RESTRICT vw = (__m128*) w;
|
||||
OPJ_INT32 i;
|
||||
/* 4x unrolled loop */
|
||||
for(i = 0; i < count >> 2; ++i){
|
||||
@ -700,8 +883,8 @@ static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m12
|
||||
}
|
||||
|
||||
void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c){
|
||||
__m128* restrict vl = (__m128*) l;
|
||||
__m128* restrict vw = (__m128*) w;
|
||||
__m128* OPJ_RESTRICT vl = (__m128*) l;
|
||||
__m128* OPJ_RESTRICT vw = (__m128*) w;
|
||||
OPJ_INT32 i;
|
||||
__m128 tmp1, tmp2, tmp3;
|
||||
tmp1 = vl[0];
|
||||
@ -729,7 +912,7 @@ void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32
|
||||
|
||||
static void opj_v4dwt_decode_step1(opj_v4_t* w, OPJ_INT32 count, const OPJ_FLOAT32 c)
|
||||
{
|
||||
OPJ_FLOAT32* restrict fw = (OPJ_FLOAT32*) w;
|
||||
OPJ_FLOAT32* OPJ_RESTRICT fw = (OPJ_FLOAT32*) w;
|
||||
OPJ_INT32 i;
|
||||
for(i = 0; i < count; ++i){
|
||||
OPJ_FLOAT32 tmp1 = fw[i*8 ];
|
||||
@ -797,7 +980,7 @@ static void opj_v4dwt_decode_step2(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_IN
|
||||
/* <summary> */
|
||||
/* Inverse 9-7 wavelet transform in 1-D. */
|
||||
/* </summary> */
|
||||
static void opj_v4dwt_decode(opj_v4dwt_t* restrict dwt)
|
||||
static void opj_v4dwt_decode(opj_v4dwt_t* OPJ_RESTRICT dwt)
|
||||
{
|
||||
OPJ_INT32 a, b;
|
||||
if(dwt->cas == 0) {
|
||||
@ -834,7 +1017,7 @@ static void opj_v4dwt_decode(opj_v4dwt_t* restrict dwt)
|
||||
/* <summary> */
|
||||
/* Inverse 9-7 wavelet transform in 2-D. */
|
||||
/* </summary> */
|
||||
OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numres)
|
||||
OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec, OPJ_UINT32 numres)
|
||||
{
|
||||
opj_v4dwt_t h;
|
||||
opj_v4dwt_t v;
|
||||
@ -846,7 +1029,21 @@ OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numr
|
||||
|
||||
OPJ_UINT32 w = (OPJ_UINT32)(tilec->x1 - tilec->x0);
|
||||
|
||||
h.wavelet = (opj_v4_t*) opj_aligned_malloc((opj_dwt_max_resolution(res, numres)+5) * sizeof(opj_v4_t));
|
||||
size_t l_data_size;
|
||||
|
||||
l_data_size = opj_dwt_max_resolution(res, numres);
|
||||
/* overflow check */
|
||||
if (l_data_size > (SIZE_MAX - 5U)) {
|
||||
/* FIXME event manager error callback */
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_data_size += 5U;
|
||||
/* overflow check */
|
||||
if (l_data_size > (SIZE_MAX / sizeof(opj_v4_t))) {
|
||||
/* FIXME event manager error callback */
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
h.wavelet = (opj_v4_t*) opj_aligned_malloc(l_data_size * sizeof(opj_v4_t));
|
||||
if (!h.wavelet) {
|
||||
/* FIXME event manager error callback */
|
||||
return OPJ_FALSE;
|
||||
@ -854,7 +1051,7 @@ OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numr
|
||||
v.wavelet = h.wavelet;
|
||||
|
||||
while( --numres) {
|
||||
OPJ_FLOAT32 * restrict aj = (OPJ_FLOAT32*) tilec->data;
|
||||
OPJ_FLOAT32 * OPJ_RESTRICT aj = (OPJ_FLOAT32*) tilec->data;
|
||||
OPJ_UINT32 bufsize = (OPJ_UINT32)((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0));
|
||||
OPJ_INT32 j;
|
||||
|
||||
|
@ -63,10 +63,11 @@ OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec);
|
||||
/**
|
||||
Inverse 5-3 wavelet transform in 2-D.
|
||||
Apply a reversible inverse DWT transform to a component of an image.
|
||||
@param tp Thread pool
|
||||
@param tilec Tile component information (current tile)
|
||||
@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.
|
||||
@ -93,7 +94,7 @@ Apply an irreversible inverse DWT transform to a component of an image.
|
||||
@param tilec Tile component information (current tile)
|
||||
@param numres Number of resolution levels to decode
|
||||
*/
|
||||
OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, OPJ_UINT32 numres);
|
||||
OPJ_BOOL opj_dwt_decode_real(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec, OPJ_UINT32 numres);
|
||||
|
||||
/**
|
||||
Get the gain of a subband for the irreversible 9-7 DWT.
|
||||
|
@ -2063,17 +2063,17 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
||||
/* testcase 4035.pdf.SIGSEGV.d8b.3375 */
|
||||
/* testcase issue427-null-image-size.jp2 */
|
||||
if ((l_image->x0 >= l_image->x1) || (l_image->y0 >= l_image->y1)) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: negative or zero image size (%d x %d)\n", l_image->x1 - l_image->x0, l_image->y1 - l_image->y0);
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: negative or zero image size (%" PRId64 " x %" PRId64 ")\n", (OPJ_INT64)l_image->x1 - l_image->x0, (OPJ_INT64)l_image->y1 - l_image->y0);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* testcase 2539.pdf.SIGFPE.706.1712 (also 3622.pdf.SIGFPE.706.2916 and 4008.pdf.SIGFPE.706.3345 and maybe more) */
|
||||
if (!(l_cp->tdx * l_cp->tdy)) {
|
||||
if ((l_cp->tdx == 0U) || (l_cp->tdy == 0U)) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker: invalid tile size (tdx: %d, tdy: %d)\n", l_cp->tdx, l_cp->tdy);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* testcase 1610.pdf.SIGSEGV.59c.681 */
|
||||
if (((OPJ_UINT64)l_image->x1) * ((OPJ_UINT64)l_image->y1) != (l_image->x1 * l_image->y1)) {
|
||||
if ((0xFFFFFFFFU / l_image->x1) < l_image->y1) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Prevent buffer overflow (x1: %d, y1: %d)\n", l_image->x1, l_image->y1);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -2094,7 +2094,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
||||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"JPWL: bad image size (%d x %d)\n",
|
||||
l_image->x1, l_image->y1);
|
||||
if (!JPWL_ASSUME || JPWL_ASSUME) {
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -2154,10 +2154,16 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
||||
if( l_img_comp->dx < 1 || l_img_comp->dx > 255 ||
|
||||
l_img_comp->dy < 1 || l_img_comp->dy > 255 ) {
|
||||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"Invalid values for comp = %d : dx=%u dy=%u\n (should be between 1 and 255 according the JPEG2000 norm)",
|
||||
"Invalid values for comp = %d : dx=%u dy=%u (should be between 1 and 255 according to the JPEG2000 norm)\n",
|
||||
i, l_img_comp->dx, l_img_comp->dy);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if( l_img_comp->prec > 38) { /* TODO openjpeg won't handle more than ? */
|
||||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"Invalid values for comp = %d : prec=%u (should be between 1 and 38 according to the JPEG2000 norm)\n",
|
||||
i, l_img_comp->prec);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (l_cp->correct) {
|
||||
@ -2270,7 +2276,7 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
||||
if (!l_cp->tcps) {
|
||||
opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT_ERROR,
|
||||
"JPWL: could not alloc tcps field of cp\n");
|
||||
if (!JPWL_ASSUME || JPWL_ASSUME) {
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -2436,22 +2442,22 @@ static OPJ_BOOL opj_j2k_write_cod( opj_j2k_t *p_j2k,
|
||||
|
||||
l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
|
||||
|
||||
opj_write_bytes(l_current_data,J2K_MS_COD,2); /* COD */
|
||||
opj_write_bytes(l_current_data,J2K_MS_COD,2); /* COD */
|
||||
l_current_data += 2;
|
||||
|
||||
opj_write_bytes(l_current_data,l_code_size-2,2); /* L_COD */
|
||||
opj_write_bytes(l_current_data,l_code_size-2,2); /* L_COD */
|
||||
l_current_data += 2;
|
||||
|
||||
opj_write_bytes(l_current_data,l_tcp->csty,1); /* Scod */
|
||||
opj_write_bytes(l_current_data,l_tcp->csty,1); /* Scod */
|
||||
++l_current_data;
|
||||
|
||||
opj_write_bytes(l_current_data,l_tcp->prg,1); /* SGcod (A) */
|
||||
opj_write_bytes(l_current_data,(OPJ_UINT32)l_tcp->prg,1); /* SGcod (A) */
|
||||
++l_current_data;
|
||||
|
||||
opj_write_bytes(l_current_data,l_tcp->numlayers,2); /* SGcod (B) */
|
||||
opj_write_bytes(l_current_data,l_tcp->numlayers,2); /* SGcod (B) */
|
||||
l_current_data+=2;
|
||||
|
||||
opj_write_bytes(l_current_data,l_tcp->mct,1); /* SGcod (C) */
|
||||
opj_write_bytes(l_current_data,l_tcp->mct,1); /* SGcod (C) */
|
||||
++l_current_data;
|
||||
|
||||
l_remaining_size -= 9;
|
||||
@ -2578,6 +2584,9 @@ static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k,
|
||||
p_j2k->cstr_info->prog = l_tcp->prg;
|
||||
p_j2k->cstr_info->numlayers = l_tcp->numlayers;
|
||||
p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32));
|
||||
if(!p_j2k->cstr_info->numdecompos){
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
for (i = 0; i < l_image->numcomps; ++i) {
|
||||
p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1;
|
||||
}
|
||||
@ -3165,7 +3174,7 @@ static void opj_j2k_write_poc_in_memory( opj_j2k_t *p_j2k,
|
||||
opj_write_bytes(l_current_data,l_current_poc->compno1,l_poc_room); /* CEpoc_i */
|
||||
l_current_data+=l_poc_room;
|
||||
|
||||
opj_write_bytes(l_current_data,l_current_poc->prg,1); /* Ppoc_i */
|
||||
opj_write_bytes(l_current_data, (OPJ_UINT32)l_current_poc->prg,1); /* Ppoc_i */
|
||||
++l_current_data;
|
||||
|
||||
/* change the value of the max layer according to the actual number of layers in the file, components and resolutions*/
|
||||
@ -4621,7 +4630,7 @@ static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k,
|
||||
opj_event_msg(p_manager, EVT_ERROR,
|
||||
"JPWL: bad component number in RGN (%d when there are only %d)\n",
|
||||
l_comp_room, l_nb_comp);
|
||||
if (!JPWL_ASSUME || JPWL_ASSUME) {
|
||||
if (!JPWL_ASSUME) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "JPWL: giving up\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -4706,7 +4715,7 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
||||
l_rates = l_tcp->rates;
|
||||
|
||||
/* Modification of the RATE >> */
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates = (( (OPJ_FLOAT32) (l_size_pixel * (OPJ_UINT32)(l_x1 - l_x0) * (OPJ_UINT32)(l_y1 - l_y0)))
|
||||
/
|
||||
((*l_rates) * (OPJ_FLOAT32)l_bits_empty)
|
||||
@ -4718,7 +4727,7 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
||||
++l_rates;
|
||||
|
||||
for (k = 1; k < l_tcp->numlayers; ++k) {
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates = (( (OPJ_FLOAT32) (l_size_pixel * (OPJ_UINT32)(l_x1 - l_x0) * (OPJ_UINT32)(l_y1 - l_y0)))
|
||||
/
|
||||
((*l_rates) * (OPJ_FLOAT32)l_bits_empty)
|
||||
@ -4741,11 +4750,11 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
||||
for (j=0;j<l_cp->tw;++j) {
|
||||
l_rates = l_tcp->rates;
|
||||
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates -= l_sot_remove;
|
||||
|
||||
if (*l_rates < 30) {
|
||||
*l_rates = 30;
|
||||
if (*l_rates < 30.0f) {
|
||||
*l_rates = 30.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4755,22 +4764,22 @@ static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
|
||||
|
||||
for (k = 1; k < l_last_res; ++k) {
|
||||
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates -= l_sot_remove;
|
||||
|
||||
if (*l_rates < *(l_rates - 1) + 10) {
|
||||
*l_rates = (*(l_rates - 1)) + 20;
|
||||
if (*l_rates < *(l_rates - 1) + 10.0f) {
|
||||
*l_rates = (*(l_rates - 1)) + 20.0f;
|
||||
}
|
||||
}
|
||||
|
||||
++l_rates;
|
||||
}
|
||||
|
||||
if (*l_rates) {
|
||||
if (*l_rates > 0.0f) {
|
||||
*l_rates -= (l_sot_remove + 2.f);
|
||||
|
||||
if (*l_rates < *(l_rates - 1) + 10) {
|
||||
*l_rates = (*(l_rates - 1)) + 20;
|
||||
if (*l_rates < *(l_rates - 1) + 10.0f) {
|
||||
*l_rates = (*(l_rates - 1)) + 20.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5362,7 +5371,7 @@ static OPJ_BOOL opj_j2k_write_mcc_record( opj_j2k_t *p_j2k,
|
||||
l_current_data+=l_nb_bytes_for_comp;
|
||||
}
|
||||
|
||||
l_tmcc = ((!p_mcc_record->m_is_irreversible)&1)<<16;
|
||||
l_tmcc = ((!p_mcc_record->m_is_irreversible) & 1U) << 16;
|
||||
|
||||
if (p_mcc_record->m_decorrelation_array) {
|
||||
l_tmcc |= p_mcc_record->m_decorrelation_array->m_index;
|
||||
@ -5396,6 +5405,7 @@ static OPJ_BOOL opj_j2k_read_mcc ( opj_j2k_t *p_j2k,
|
||||
OPJ_UINT32 l_nb_collections;
|
||||
OPJ_UINT32 l_nb_comps;
|
||||
OPJ_UINT32 l_nb_bytes_by_comp;
|
||||
OPJ_BOOL l_new_mcc = OPJ_FALSE;
|
||||
|
||||
/* preconditions */
|
||||
assert(p_header_data != 00);
|
||||
@ -5457,6 +5467,7 @@ static OPJ_BOOL opj_j2k_read_mcc ( opj_j2k_t *p_j2k,
|
||||
memset(l_mcc_record,0,(l_tcp->m_nb_max_mcc_records-l_tcp->m_nb_mcc_records) * sizeof(opj_simple_mcc_decorrelation_data_t));
|
||||
}
|
||||
l_mcc_record = l_tcp->m_mcc_records + l_tcp->m_nb_mcc_records;
|
||||
l_new_mcc = OPJ_TRUE;
|
||||
}
|
||||
l_mcc_record->m_index = l_indix;
|
||||
|
||||
@ -5592,7 +5603,9 @@ static OPJ_BOOL opj_j2k_read_mcc ( opj_j2k_t *p_j2k,
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
++l_tcp->m_nb_mcc_records;
|
||||
if (l_new_mcc) {
|
||||
++l_tcp->m_nb_mcc_records;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
@ -5935,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 */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
@ -5972,6 +6014,17 @@ opj_j2k_t* opj_j2k_create_compress(void)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -7477,7 +7530,7 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2
|
||||
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);
|
||||
p_j2k->m_tcd = 00;
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
|
||||
@ -7558,6 +7611,9 @@ void opj_j2k_destroy (opj_j2k_t *p_j2k)
|
||||
opj_image_destroy(p_j2k->m_output_image);
|
||||
p_j2k->m_output_image = NULL;
|
||||
|
||||
opj_thread_pool_destroy(p_j2k->m_tp);
|
||||
p_j2k->m_tp = NULL;
|
||||
|
||||
opj_free(p_j2k);
|
||||
}
|
||||
|
||||
@ -8208,8 +8264,14 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
|
||||
|
||||
/* Allocate output component buffer if necessary */
|
||||
if (!l_img_comp_dest->data) {
|
||||
OPJ_SIZE_T l_width = l_img_comp_dest->w;
|
||||
OPJ_SIZE_T l_height = l_img_comp_dest->h;
|
||||
|
||||
l_img_comp_dest->data = (OPJ_INT32*) opj_calloc((OPJ_SIZE_T)l_img_comp_dest->w * (OPJ_SIZE_T)l_img_comp_dest->h, sizeof(OPJ_INT32));
|
||||
if ((l_height == 0U) || (l_width > (SIZE_MAX / l_height))) {
|
||||
/* would overflow */
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_img_comp_dest->data = (OPJ_INT32*) opj_calloc(l_width * l_height, sizeof(OPJ_INT32));
|
||||
if (! l_img_comp_dest->data) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -8649,6 +8711,17 @@ opj_j2k_t* opj_j2k_create_decompress(void)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -8880,6 +8953,10 @@ static OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k,
|
||||
|
||||
opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1); /* SPcoc (G) */
|
||||
++l_current_ptr;
|
||||
if (l_tccp->cblksty & 0xC0U) { /* 2 msb are reserved, assume we can't read */
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc element, Invalid code-block style found\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
opj_read_bytes(l_current_ptr,&l_tccp->qmfbid ,1); /* SPcoc (H) */
|
||||
++l_current_ptr;
|
||||
@ -9334,16 +9411,19 @@ void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream)
|
||||
|
||||
/* Dump the codestream info from main header */
|
||||
if (flag & OPJ_J2K_MH_INFO){
|
||||
opj_j2k_dump_MH_info(p_j2k, out_stream);
|
||||
if (p_j2k->m_private_image)
|
||||
opj_j2k_dump_MH_info(p_j2k, out_stream);
|
||||
}
|
||||
/* Dump all tile/codestream info */
|
||||
if (flag & OPJ_J2K_TCH_INFO){
|
||||
OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
|
||||
OPJ_UINT32 i;
|
||||
opj_tcp_t * l_tcp = p_j2k->m_cp.tcps;
|
||||
for (i=0;i<l_nb_tiles;++i) {
|
||||
opj_j2k_dump_tile_info( l_tcp,(OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream);
|
||||
++l_tcp;
|
||||
if (p_j2k->m_private_image) {
|
||||
for (i=0;i<l_nb_tiles;++i) {
|
||||
opj_j2k_dump_tile_info( l_tcp,(OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream);
|
||||
++l_tcp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10918,7 +10998,7 @@ static OPJ_BOOL opj_j2k_create_tcd( opj_j2k_t *p_j2k,
|
||||
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);
|
||||
p_j2k->m_tcd = 00;
|
||||
return OPJ_FALSE;
|
||||
|
@ -228,7 +228,7 @@ typedef struct opj_simple_mcc_decorrelation_data
|
||||
OPJ_UINT32 m_nb_comps;
|
||||
opj_mct_data_t * m_decorrelation_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;
|
||||
|
||||
@ -306,11 +306,11 @@ typedef struct opj_tcp
|
||||
|
||||
/***** FLAGS *******/
|
||||
/** 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 */
|
||||
OPJ_UINT32 ppt : 1;
|
||||
OPJ_BITFIELD ppt : 1;
|
||||
/** indicates if a POC marker has been used O:NO, 1:YES */
|
||||
OPJ_UINT32 POC : 1;
|
||||
OPJ_BITFIELD POC : 1;
|
||||
} opj_tcp_t;
|
||||
|
||||
|
||||
@ -327,13 +327,13 @@ typedef struct opj_encoding_param
|
||||
/** Flag determining tile part generation*/
|
||||
OPJ_BYTE m_tp_flag;
|
||||
/** allocation by rate/distortion */
|
||||
OPJ_UINT32 m_disto_alloc : 1;
|
||||
OPJ_BITFIELD m_disto_alloc : 1;
|
||||
/** allocation by fixed layer */
|
||||
OPJ_UINT32 m_fixed_alloc : 1;
|
||||
OPJ_BITFIELD m_fixed_alloc : 1;
|
||||
/** add fixed_quality */
|
||||
OPJ_UINT32 m_fixed_quality : 1;
|
||||
OPJ_BITFIELD m_fixed_quality : 1;
|
||||
/** Enabling Tile part generation*/
|
||||
OPJ_UINT32 m_tp_on : 1;
|
||||
OPJ_BITFIELD m_tp_on : 1;
|
||||
}
|
||||
opj_encoding_param_t;
|
||||
|
||||
@ -453,9 +453,9 @@ typedef struct opj_cp
|
||||
|
||||
/******** FLAGS *********/
|
||||
/** 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 */
|
||||
OPJ_UINT32 m_is_decoder : 1;
|
||||
OPJ_BITFIELD m_is_decoder : 1;
|
||||
/* <<UniPG */
|
||||
} opj_cp_t;
|
||||
|
||||
@ -497,12 +497,12 @@ typedef struct opj_j2k_dec
|
||||
*/
|
||||
OPJ_BOOL m_last_tile_part;
|
||||
/** to tell that a tile can be decoded. */
|
||||
OPJ_UINT32 m_can_decode : 1;
|
||||
OPJ_UINT32 m_discard_tiles : 1;
|
||||
OPJ_UINT32 m_skip_data : 1;
|
||||
OPJ_BITFIELD m_can_decode : 1;
|
||||
OPJ_BITFIELD m_discard_tiles : 1;
|
||||
OPJ_BITFIELD m_skip_data : 1;
|
||||
/** TNsot correction : see issue 254 **/
|
||||
OPJ_UINT32 m_nb_tile_parts_correction_checked : 1;
|
||||
OPJ_UINT32 m_nb_tile_parts_correction : 1;
|
||||
OPJ_BITFIELD m_nb_tile_parts_correction_checked : 1;
|
||||
OPJ_BITFIELD m_nb_tile_parts_correction : 1;
|
||||
|
||||
} opj_j2k_dec_t;
|
||||
|
||||
@ -589,6 +589,12 @@ typedef struct opj_j2k
|
||||
|
||||
/** the current tile coder/decoder **/
|
||||
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;
|
||||
|
||||
@ -607,6 +613,8 @@ Decoding parameters are returned in j2k->cp.
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
@ -552,6 +552,11 @@ static OPJ_BOOL opj_jp2_read_ihdr( opj_jp2_t *jp2,
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
if (jp2->comps != NULL) {
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Ignoring ihdr box. First ihdr box already read\n");
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
if (p_image_header_size != 14) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Bad image header box (bad size)\n");
|
||||
return OPJ_FALSE;
|
||||
@ -563,6 +568,11 @@ static OPJ_BOOL opj_jp2_read_ihdr( opj_jp2_t *jp2,
|
||||
p_image_header_data += 4;
|
||||
opj_read_bytes(p_image_header_data,&(jp2->numcomps),2); /* NC */
|
||||
p_image_header_data += 2;
|
||||
|
||||
if ((jp2->numcomps - 1U) >= 16384U) { /* unsigned underflow is well defined: 1U <= jp2->numcomps <= 16384U */
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Invalid number of components (ihdr)\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* allocate memory for components */
|
||||
jp2->comps = (opj_jp2_comps_t*) opj_calloc(jp2->numcomps, sizeof(opj_jp2_comps_t));
|
||||
@ -646,12 +656,13 @@ static OPJ_BYTE * opj_jp2_write_bpcc( opj_jp2_t *jp2,
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
/* room for 8 bytes for box and 1 byte for each component */
|
||||
OPJ_UINT32 l_bpcc_size = 8 + jp2->numcomps;
|
||||
OPJ_UINT32 l_bpcc_size;
|
||||
OPJ_BYTE * l_bpcc_data,* l_current_bpcc_ptr;
|
||||
|
||||
/* preconditions */
|
||||
assert(jp2 != 00);
|
||||
assert(p_nb_bytes_written != 00);
|
||||
l_bpcc_size = 8 + jp2->numcomps;
|
||||
|
||||
l_bpcc_data = (OPJ_BYTE *) opj_calloc(1,l_bpcc_size);
|
||||
if (l_bpcc_data == 00) {
|
||||
@ -1404,6 +1415,10 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
|
||||
OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
|
||||
|
||||
cielab = (OPJ_UINT32*)opj_malloc(9 * sizeof(OPJ_UINT32));
|
||||
if(cielab == NULL){
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for cielab\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
cielab[0] = 14; /* enumcs */
|
||||
|
||||
/* default values */
|
||||
@ -1639,7 +1654,7 @@ static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
|
||||
opj_event_mgr_t * p_manager )
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
OPJ_UINT32 l_ftyp_size = 16 + 4 * jp2->numcl;
|
||||
OPJ_UINT32 l_ftyp_size;
|
||||
OPJ_BYTE * l_ftyp_data, * l_current_data_ptr;
|
||||
OPJ_BOOL l_result;
|
||||
|
||||
@ -1647,6 +1662,7 @@ static OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
|
||||
assert(cio != 00);
|
||||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
l_ftyp_size = 16 + 4 * jp2->numcl;
|
||||
|
||||
l_ftyp_data = (OPJ_BYTE *) opj_calloc(1,l_ftyp_size);
|
||||
|
||||
@ -1758,7 +1774,12 @@ void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
|
||||
|
||||
/* further JP2 initializations go here */
|
||||
jp2->color.jp2_has_colr = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
@ -1804,7 +1825,6 @@ OPJ_BOOL opj_jp2_setup_encoder( opj_jp2_t *jp2,
|
||||
jp2->numcl = 1;
|
||||
jp2->cl = (OPJ_UINT32*) opj_malloc(jp2->numcl * sizeof(OPJ_UINT32));
|
||||
if (!jp2->cl){
|
||||
jp2->cl = NULL;
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory when setup the JP2 encoder\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -1815,7 +1835,6 @@ OPJ_BOOL opj_jp2_setup_encoder( opj_jp2_t *jp2,
|
||||
jp2->numcomps = image->numcomps; /* NC */
|
||||
jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
|
||||
if (!jp2->comps) {
|
||||
jp2->comps = NULL;
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory when setup the JP2 encoder\n");
|
||||
/* Memory of jp2->cl will be freed by opj_jp2_destroy */
|
||||
return OPJ_FALSE;
|
||||
|
@ -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);
|
||||
|
||||
OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads);
|
||||
|
||||
/**
|
||||
* Decode an image from a JPEG-2000 file stream
|
||||
* @param jp2 JP2 decompressor handle
|
||||
|
@ -74,9 +74,9 @@ const OPJ_FLOAT64 * opj_mct_get_mct_norms_real ()
|
||||
/* </summary> */
|
||||
#ifdef __SSE2__
|
||||
void opj_mct_encode(
|
||||
OPJ_INT32* restrict c0,
|
||||
OPJ_INT32* restrict c1,
|
||||
OPJ_INT32* restrict c2,
|
||||
OPJ_INT32* OPJ_RESTRICT c0,
|
||||
OPJ_INT32* OPJ_RESTRICT c1,
|
||||
OPJ_INT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -116,9 +116,9 @@ void opj_mct_encode(
|
||||
}
|
||||
#else
|
||||
void opj_mct_encode(
|
||||
OPJ_INT32* restrict c0,
|
||||
OPJ_INT32* restrict c1,
|
||||
OPJ_INT32* restrict c2,
|
||||
OPJ_INT32* OPJ_RESTRICT c0,
|
||||
OPJ_INT32* OPJ_RESTRICT c1,
|
||||
OPJ_INT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -143,9 +143,9 @@ void opj_mct_encode(
|
||||
/* </summary> */
|
||||
#ifdef __SSE2__
|
||||
void opj_mct_decode(
|
||||
OPJ_INT32* restrict c0,
|
||||
OPJ_INT32* restrict c1,
|
||||
OPJ_INT32* restrict c2,
|
||||
OPJ_INT32* OPJ_RESTRICT c0,
|
||||
OPJ_INT32* OPJ_RESTRICT c1,
|
||||
OPJ_INT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -178,9 +178,9 @@ void opj_mct_decode(
|
||||
}
|
||||
#else
|
||||
void opj_mct_decode(
|
||||
OPJ_INT32* restrict c0,
|
||||
OPJ_INT32* restrict c1,
|
||||
OPJ_INT32* restrict c2,
|
||||
OPJ_INT32* OPJ_RESTRICT c0,
|
||||
OPJ_INT32* OPJ_RESTRICT c1,
|
||||
OPJ_INT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
@ -210,9 +210,9 @@ OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno) {
|
||||
/* </summary> */
|
||||
#ifdef __SSE4_1__
|
||||
void opj_mct_encode_real(
|
||||
OPJ_INT32* restrict c0,
|
||||
OPJ_INT32* restrict c1,
|
||||
OPJ_INT32* restrict c2,
|
||||
OPJ_INT32* OPJ_RESTRICT c0,
|
||||
OPJ_INT32* OPJ_RESTRICT c1,
|
||||
OPJ_INT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_SIZE_T i;
|
||||
@ -351,9 +351,9 @@ void opj_mct_encode_real(
|
||||
}
|
||||
#else
|
||||
void opj_mct_encode_real(
|
||||
OPJ_INT32* restrict c0,
|
||||
OPJ_INT32* restrict c1,
|
||||
OPJ_INT32* restrict c2,
|
||||
OPJ_INT32* OPJ_RESTRICT c0,
|
||||
OPJ_INT32* OPJ_RESTRICT c1,
|
||||
OPJ_INT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
@ -375,9 +375,9 @@ void opj_mct_encode_real(
|
||||
/* Inverse irreversible MCT. */
|
||||
/* </summary> */
|
||||
void opj_mct_decode_real(
|
||||
OPJ_FLOAT32* restrict c0,
|
||||
OPJ_FLOAT32* restrict c1,
|
||||
OPJ_FLOAT32* restrict c2,
|
||||
OPJ_FLOAT32* OPJ_RESTRICT c0,
|
||||
OPJ_FLOAT32* OPJ_RESTRICT c1,
|
||||
OPJ_FLOAT32* OPJ_RESTRICT c2,
|
||||
OPJ_UINT32 n)
|
||||
{
|
||||
OPJ_UINT32 i;
|
||||
|
@ -60,7 +60,7 @@ Apply a reversible multi-component transform to an image
|
||||
@param c2 Samples blue component
|
||||
@param n Number of samples for each component
|
||||
*/
|
||||
void opj_mct_encode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
|
||||
void opj_mct_encode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n);
|
||||
/**
|
||||
Apply a reversible multi-component inverse transform to an image
|
||||
@param c0 Samples for luminance component
|
||||
@ -68,7 +68,7 @@ Apply a reversible multi-component inverse transform to an image
|
||||
@param c2 Samples for blue chrominance component
|
||||
@param n Number of samples for each component
|
||||
*/
|
||||
void opj_mct_decode(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
|
||||
void opj_mct_decode(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n);
|
||||
/**
|
||||
Get norm of the basis function used for the reversible multi-component transform
|
||||
@param compno Number of the component (0->Y, 1->U, 2->V)
|
||||
@ -83,7 +83,7 @@ Apply an irreversible multi-component transform to an image
|
||||
@param c2 Samples blue component
|
||||
@param n Number of samples for each component
|
||||
*/
|
||||
void opj_mct_encode_real(OPJ_INT32 *c0, OPJ_INT32 *c1, OPJ_INT32 *c2, OPJ_UINT32 n);
|
||||
void opj_mct_encode_real(OPJ_INT32* OPJ_RESTRICT c0, OPJ_INT32* OPJ_RESTRICT c1, OPJ_INT32* OPJ_RESTRICT c2, OPJ_UINT32 n);
|
||||
/**
|
||||
Apply an irreversible multi-component inverse transform to an image
|
||||
@param c0 Samples for luminance component
|
||||
@ -91,7 +91,7 @@ Apply an irreversible multi-component inverse transform to an image
|
||||
@param c2 Samples for blue chrominance component
|
||||
@param n Number of samples for each component
|
||||
*/
|
||||
void opj_mct_decode_real(OPJ_FLOAT32* c0, OPJ_FLOAT32* c1, OPJ_FLOAT32* c2, OPJ_UINT32 n);
|
||||
void opj_mct_decode_real(OPJ_FLOAT32* OPJ_RESTRICT c0, OPJ_FLOAT32* OPJ_RESTRICT c1, OPJ_FLOAT32* OPJ_RESTRICT c2, OPJ_UINT32 n);
|
||||
/**
|
||||
Get norm of the basis function used for the irreversible multi-component transform
|
||||
@param compno Number of the component (0->Y, 1->U, 2->V)
|
||||
|
@ -70,28 +70,6 @@ Fill mqc->c with 1's for flushing
|
||||
@param mqc MQC handle
|
||||
*/
|
||||
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);
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
@ -203,13 +181,20 @@ static opj_mqc_state_t mqc_states[47 * 2] = {
|
||||
*/
|
||||
|
||||
static void opj_mqc_byteout(opj_mqc_t *mqc) {
|
||||
if (*mqc->bp == 0xff) {
|
||||
/* avoid accessing uninitialized memory*/
|
||||
if (mqc->bp == mqc->start-1) {
|
||||
mqc->bp++;
|
||||
*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
|
||||
mqc->c &= 0x7ffff;
|
||||
mqc->ct = 8;
|
||||
}
|
||||
else if (*mqc->bp == 0xff) {
|
||||
mqc->bp++;
|
||||
*mqc->bp = (OPJ_BYTE)(mqc->c >> 20);
|
||||
mqc->c &= 0xfffff;
|
||||
mqc->ct = 7;
|
||||
} else {
|
||||
if ((mqc->c & 0x8000000) == 0) { /* ((mqc->c&0x8000000)==0) CHANGE */
|
||||
if ((mqc->c & 0x8000000) == 0) {
|
||||
mqc->bp++;
|
||||
*mqc->bp = (OPJ_BYTE)(mqc->c >> 19);
|
||||
mqc->c &= 0x7ffff;
|
||||
@ -277,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
|
||||
@ -395,9 +304,6 @@ void opj_mqc_init_enc(opj_mqc_t *mqc, OPJ_BYTE *bp) {
|
||||
mqc->c = 0;
|
||||
mqc->bp = bp - 1;
|
||||
mqc->ct = 12;
|
||||
if (*mqc->bp == 0xff) {
|
||||
mqc->ct = 13;
|
||||
}
|
||||
mqc->start = bp;
|
||||
}
|
||||
|
||||
@ -581,25 +487,6 @@ OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len) {
|
||||
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) {
|
||||
OPJ_UINT32 i;
|
||||
for (i = 0; i < MQC_NUMCTXS; i++) {
|
||||
|
@ -77,11 +77,14 @@ typedef struct opj_mqc {
|
||||
OPJ_BYTE *end;
|
||||
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
|
||||
opj_mqc_state_t **curctx;
|
||||
const OPJ_BYTE *lut_ctxno_zc_orient; /* lut_ctxno_zc shifted by 256 * bandno */
|
||||
#ifdef MQC_PERF_OPT
|
||||
unsigned char *buffer;
|
||||
#endif
|
||||
} opj_mqc_t;
|
||||
|
||||
#include "mqc_inl.h"
|
||||
|
||||
/** @name Exported functions */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
@ -198,7 +201,7 @@ Decode a symbol
|
||||
@param mqc MQC handle
|
||||
@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,
|
||||
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();
|
||||
|
||||
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_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);
|
||||
|
||||
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_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_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.
|
||||
*
|
||||
@ -1554,6 +1573,19 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT( opj_cparameters_t *parameters,
|
||||
OPJ_INT32 * p_dc_shift,
|
||||
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
|
||||
|
@ -113,6 +113,7 @@ typedef struct opj_codec_private
|
||||
OPJ_BOOL (*opj_set_decoded_resolution_factor) ( void * p_codec,
|
||||
OPJ_UINT32 res_factor,
|
||||
opj_event_mgr_t * p_manager);
|
||||
|
||||
} 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);
|
||||
opj_codestream_info_v2_t* (*opj_get_codec_info)(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;
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
/*
|
||||
Use fseeko() and ftello() if they are available since they use
|
||||
@ -102,22 +103,33 @@
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/* Ignore GCC attributes if this is not GCC */
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x) /* __attribute__(x) */
|
||||
#endif
|
||||
|
||||
|
||||
/* Are restricted pointers available? (C99) */
|
||||
#if (__STDC_VERSION__ != 199901L)
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define OPJ_RESTRICT restrict
|
||||
#else
|
||||
/* Not a C99 compiler */
|
||||
#ifdef __GNUC__
|
||||
#define restrict __restrict__
|
||||
#if defined(__GNUC__)
|
||||
#define OPJ_RESTRICT __restrict__
|
||||
|
||||
/*
|
||||
vc14 (2015) outputs wrong results.
|
||||
Need to check OPJ_RESTRICT usage (or a bug in vc14)
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#define OPJ_RESTRICT __restrict
|
||||
*/
|
||||
#else
|
||||
#define restrict /* restrict */
|
||||
#define OPJ_RESTRICT /* restrict */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __has_attribute
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define OPJ_NOSANITIZE(kind) __attribute__((no_sanitize(kind)))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef OPJ_NOSANITIZE
|
||||
#define OPJ_NOSANITIZE(kind)
|
||||
#endif
|
||||
|
||||
|
||||
/* MSVC before 2013 and Borland C do not have lrintf */
|
||||
@ -172,6 +184,9 @@ static INLINE long opj_lrintf(float f) {
|
||||
# pragma intrinsic(__emul)
|
||||
#endif
|
||||
|
||||
/* Type to use for bit-fields in internal headers */
|
||||
typedef unsigned int OPJ_BITFIELD;
|
||||
|
||||
#include "opj_inttypes.h"
|
||||
#include "opj_clock.h"
|
||||
#include "opj_malloc.h"
|
||||
@ -180,6 +195,9 @@ static INLINE long opj_lrintf(float f) {
|
||||
#include "bio.h"
|
||||
#include "cio.h"
|
||||
|
||||
#include "thread.h"
|
||||
#include "tls_keys.h"
|
||||
|
||||
#include "image.h"
|
||||
#include "invert.h"
|
||||
#include "j2k.h"
|
||||
|
@ -196,10 +196,10 @@ void * opj_malloc(size_t size)
|
||||
}
|
||||
void * opj_calloc(size_t num, size_t size)
|
||||
{
|
||||
if (size == 0U) { /* prevent implementation defined behavior of realloc */
|
||||
if (num == 0 || size == 0) {
|
||||
/* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
/* according to C89 standard, num == 0 shall return a valid pointer */
|
||||
return calloc(num, size);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,9 @@ int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
|
||||
OPJ_OFF_T lenp = 0;
|
||||
|
||||
box = (opj_jp2_box_t *)opj_calloc( (size_t)cstr_info.numcomps, sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for( i=0;i<2;i++){
|
||||
if (i)
|
||||
opj_stream_seek( cio, lenp, p_manager);
|
||||
|
@ -747,10 +747,12 @@ static void opj_get_all_encoding_parameters( const opj_image_t *p_image,
|
||||
}
|
||||
|
||||
/* use custom size for precincts*/
|
||||
l_level_no = l_tccp->numresolutions - 1;
|
||||
l_level_no = l_tccp->numresolutions;
|
||||
for (resno = 0; resno < l_tccp->numresolutions; ++resno) {
|
||||
OPJ_UINT32 l_dx, l_dy;
|
||||
|
||||
--l_level_no;
|
||||
|
||||
/* precinct width and height*/
|
||||
l_pdx = l_tccp->prcw[resno];
|
||||
l_pdy = l_tccp->prch[resno];
|
||||
@ -782,7 +784,6 @@ static void opj_get_all_encoding_parameters( const opj_image_t *p_image,
|
||||
*p_max_prec = l_product;
|
||||
}
|
||||
|
||||
--l_level_no;
|
||||
}
|
||||
++l_tccp;
|
||||
++l_img_comp;
|
||||
@ -1236,9 +1237,15 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
|
||||
l_current_pi = l_pi;
|
||||
|
||||
/* memory allocation for include */
|
||||
l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
|
||||
if
|
||||
(!l_current_pi->include)
|
||||
/* prevent an integer overflow issue */
|
||||
/* 0 < l_tcp->numlayers < 65536 c.f. opj_j2k_read_cod in j2k.c */
|
||||
l_current_pi->include = 00;
|
||||
if (l_step_l <= (SIZE_MAX / (l_tcp->numlayers + 1U)))
|
||||
{
|
||||
l_current_pi->include = (OPJ_INT16*) opj_calloc((size_t)(l_tcp->numlayers + 1U) * l_step_l, sizeof(OPJ_INT16));
|
||||
}
|
||||
|
||||
if (!l_current_pi->include)
|
||||
{
|
||||
opj_free(l_tmp_data);
|
||||
opj_free(l_tmp_ptr);
|
||||
|
@ -61,7 +61,9 @@ int opj_write_ppix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
|
||||
|
||||
lenp = -1;
|
||||
box = (opj_jp2_box_t *)opj_calloc( (size_t)cstr_info.numcomps, sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for (i=0;i<2;i++){
|
||||
if (i)
|
||||
|
||||
|
@ -88,7 +88,7 @@ OPJ_UINT32 opj_raw_decode(opj_raw_t *raw) {
|
||||
}
|
||||
}
|
||||
raw->ct--;
|
||||
d = (raw->c >> raw->ct) & 0x01;
|
||||
d = ((OPJ_UINT32)raw->c >> raw->ct) & 0x01U;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
1437
src/lib/openjp2/t1.c
1437
src/lib/openjp2/t1.c
File diff suppressed because it is too large
Load Diff
@ -50,48 +50,74 @@ in T1.C are used by some function in TCD.C.
|
||||
/* ----------------------------------------------------------------------- */
|
||||
#define T1_NMSEDEC_BITS 7
|
||||
|
||||
#define T1_SIG_NE 0x0001 /**< Context orientation : North-East direction */
|
||||
#define T1_SIG_SE 0x0002 /**< Context orientation : South-East direction */
|
||||
#define T1_SIG_SW 0x0004 /**< Context orientation : South-West direction */
|
||||
#define T1_SIG_NW 0x0008 /**< Context orientation : North-West direction */
|
||||
#define T1_SIG_N 0x0010 /**< Context orientation : North direction */
|
||||
#define T1_SIG_E 0x0020 /**< Context orientation : East direction */
|
||||
#define T1_SIG_S 0x0040 /**< Context orientation : South direction */
|
||||
#define T1_SIG_W 0x0080 /**< Context orientation : West direction */
|
||||
/* CAUTION: the value of those constants must not be changed, otherwise the */
|
||||
/* optimization of opj_t1_updateflags() will break! */
|
||||
/* BEGINNING of flags that apply to opj_flag_t */
|
||||
#define T1_SIG_NE 0x0001U /**< Context orientation : North-East direction */
|
||||
#define T1_SIG_SE 0x0002U /**< Context orientation : South-East direction */
|
||||
#define T1_SIG_SW 0x0004U /**< Context orientation : South-West direction */
|
||||
#define T1_SIG_NW 0x0008U /**< Context orientation : North-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_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
|
||||
|
||||
#define T1_SGN_N 0x0100
|
||||
#define T1_SGN_E 0x0200
|
||||
#define T1_SGN_S 0x0400
|
||||
#define T1_SGN_W 0x0800
|
||||
#define T1_SGN_N 0x0100U
|
||||
#define T1_SGN_E 0x0200U
|
||||
#define T1_SGN_S 0x0400U
|
||||
#define T1_SGN_W 0x0800U
|
||||
#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
|
||||
|
||||
#define T1_SIG 0x1000
|
||||
#define T1_REFINE 0x2000
|
||||
#define T1_VISIT 0x4000
|
||||
#define T1_SIG 0x1000U /**< No longer used by decoder */
|
||||
#define T1_REFINE 0x2000U /**< No longer used by decoder */
|
||||
#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_SC 5
|
||||
#define T1_NUMCTXS_ZC 9
|
||||
#define T1_NUMCTXS_SC 5
|
||||
#define T1_NUMCTXS_MAG 3
|
||||
#define T1_NUMCTXS_AGG 1
|
||||
#define T1_NUMCTXS_UNI 1
|
||||
|
||||
#define T1_CTXNO_ZC 0
|
||||
#define T1_CTXNO_SC (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
|
||||
#define T1_CTXNO_ZC 0
|
||||
#define T1_CTXNO_SC (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
|
||||
#define T1_CTXNO_MAG (T1_CTXNO_SC+T1_NUMCTXS_SC)
|
||||
#define T1_CTXNO_AGG (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
|
||||
#define T1_CTXNO_UNI (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
|
||||
#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
|
||||
#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
|
||||
|
||||
#define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
|
||||
|
||||
#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)*/
|
||||
|
||||
/* 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)
|
||||
@ -105,11 +131,17 @@ typedef struct opj_t1 {
|
||||
|
||||
OPJ_INT32 *data;
|
||||
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 h;
|
||||
OPJ_UINT32 datasize;
|
||||
OPJ_UINT32 flagssize;
|
||||
OPJ_UINT32 flags_stride;
|
||||
OPJ_UINT32 colflags_size;
|
||||
OPJ_UINT32 data_stride;
|
||||
OPJ_BOOL encoder;
|
||||
} opj_t1_t;
|
||||
@ -140,7 +172,8 @@ Decode the code-blocks of a tile
|
||||
@param tilec The tile to decode
|
||||
@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_tccp_t* tccp);
|
||||
|
||||
|
@ -38,18 +38,21 @@
|
||||
|
||||
#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;
|
||||
n = 0;
|
||||
h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
|
||||
v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
|
||||
d = ((f & T1_SIG_NW) != 0) + ((f & T1_SIG_NE) != 0) + ((f & T1_SIG_SE) != 0) + ((f & T1_SIG_SW) != 0);
|
||||
n = 0;
|
||||
t = 0;
|
||||
hv = 0;
|
||||
|
||||
switch (orient) {
|
||||
case 2:
|
||||
t = h;
|
||||
h = v;
|
||||
v = t;
|
||||
/* fall through */
|
||||
case 0:
|
||||
case 1:
|
||||
if (!h) {
|
||||
@ -110,7 +113,7 @@ static int t1_init_ctxno_zc(int f, int orient) {
|
||||
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;
|
||||
n = 0;
|
||||
|
||||
@ -151,7 +154,7 @@ static int t1_init_ctxno_sc(int f) {
|
||||
return (T1_CTXNO_SC + n);
|
||||
}
|
||||
|
||||
static int t1_init_spb(int f) {
|
||||
static int t1_init_spb(unsigned int f) {
|
||||
int hc, vc, n;
|
||||
|
||||
hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
||||
@ -189,7 +192,7 @@ static void dump_array16(int array[],int size){
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j;
|
||||
unsigned int i, j;
|
||||
double u, v, t;
|
||||
|
||||
int lut_ctxno_zc[1024];
|
||||
@ -202,47 +205,47 @@ int main(int argc, char **argv)
|
||||
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
|
||||
|
||||
/* lut_ctxno_zc */
|
||||
for (j = 0; j < 4; ++j) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
int orient = j;
|
||||
if (orient == 2) {
|
||||
orient = 1;
|
||||
} else if (orient == 1) {
|
||||
orient = 2;
|
||||
for (j = 0U; j < 4U; ++j) {
|
||||
for (i = 0U; i < 256U; ++i) {
|
||||
unsigned int orient = j;
|
||||
if (orient == 2U) {
|
||||
orient = 1U;
|
||||
} else if (orient == 1U) {
|
||||
orient = 2U;
|
||||
}
|
||||
lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
printf("static OPJ_BYTE lut_ctxno_zc[1024] = {\n ");
|
||||
for (i = 0; i < 1023; ++i) {
|
||||
printf("static const OPJ_BYTE lut_ctxno_zc[1024] = {\n ");
|
||||
for (i = 0U; i < 1023U; ++i) {
|
||||
printf("%i, ", lut_ctxno_zc[i]);
|
||||
if(!((i+1)&0x1f))
|
||||
if(!((i+1U)&0x1fU))
|
||||
printf("\n ");
|
||||
}
|
||||
printf("%i\n};\n\n", lut_ctxno_zc[1023]);
|
||||
|
||||
/* lut_ctxno_sc */
|
||||
printf("static OPJ_BYTE lut_ctxno_sc[256] = {\n ");
|
||||
for (i = 0; i < 255; ++i) {
|
||||
printf("static const OPJ_BYTE lut_ctxno_sc[256] = {\n ");
|
||||
for (i = 0U; i < 255U; ++i) {
|
||||
printf("0x%x, ", t1_init_ctxno_sc(i << 4));
|
||||
if(!((i+1)&0xf))
|
||||
if(!((i+1U)&0xfU))
|
||||
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 */
|
||||
printf("static OPJ_BYTE lut_spb[256] = {\n ");
|
||||
for (i = 0; i < 255; ++i) {
|
||||
printf("static const OPJ_BYTE lut_spb[256] = {\n ");
|
||||
for (i = 0U; i < 255U; ++i) {
|
||||
printf("%i, ", t1_init_spb(i << 4));
|
||||
if(!((i+1)&0x1f))
|
||||
if(!((i+1U)&0x1fU))
|
||||
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 */
|
||||
/* 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);
|
||||
u = t;
|
||||
v = t - 1.5;
|
||||
@ -266,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));
|
||||
}
|
||||
|
||||
printf("static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
|
||||
printf("static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_sig, 1U << T1_NMSEDEC_BITS);
|
||||
|
||||
printf("static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
|
||||
printf("static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_sig0, 1U << T1_NMSEDEC_BITS);
|
||||
|
||||
printf("static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
|
||||
printf("static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_ref, 1U << T1_NMSEDEC_BITS);
|
||||
|
||||
printf("static OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
|
||||
printf("static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||
dump_array16(lut_nmsedec_ref0, 1U << T1_NMSEDEC_BITS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* 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,
|
||||
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,
|
||||
@ -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
|
||||
};
|
||||
|
||||
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, 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,
|
||||
@ -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
|
||||
};
|
||||
|
||||
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, 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,
|
||||
@ -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
|
||||
};
|
||||
|
||||
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,
|
||||
@ -84,7 +84,7 @@ static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
|
||||
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,
|
||||
0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
|
||||
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
|
||||
};
|
||||
|
||||
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,
|
||||
0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080,
|
||||
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
|
||||
};
|
||||
|
||||
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,
|
||||
0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300,
|
||||
0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00,
|
||||
|
@ -868,9 +868,14 @@ static OPJ_BOOL opj_t2_read_packet_header( opj_t2_t* p_t2,
|
||||
|
||||
/* reset tagtrees */
|
||||
for (bandno = 0; bandno < l_res->numbands; ++bandno) {
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if ( ! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) ) {
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
if (!(p_pi->precno < (l_band->precincts_data_size / sizeof(opj_tcd_precinct_t)))) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Invalid precinct\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
||||
opj_tgt_reset(l_prc->incltree);
|
||||
opj_tgt_reset(l_prc->imsbtree);
|
||||
l_cblk = l_prc->cblks.dec;
|
||||
|
@ -486,8 +486,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
||||
for (layno = 0; layno < tcd_tcp->numlayers; layno++) {
|
||||
OPJ_FLOAT64 lo = min;
|
||||
OPJ_FLOAT64 hi = max;
|
||||
OPJ_BOOL success = OPJ_FALSE;
|
||||
OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? opj_uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
|
||||
OPJ_UINT32 maxlen = tcd_tcp->rates[layno] > 0.0f ? opj_uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
|
||||
OPJ_FLOAT64 goodthresh = 0;
|
||||
OPJ_FLOAT64 stable_thresh = 0;
|
||||
OPJ_UINT32 i;
|
||||
@ -500,7 +499,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
||||
-r xx,yy,zz,0 (disto_alloc == 1 and rates == 0)
|
||||
-q xx,yy,zz,0 (fixed_quality == 1 and distoratio == 0)
|
||||
==> possible to have some lossy layers and the last layer for sure lossless */
|
||||
if ( ((cp->m_specific_param.m_enc.m_disto_alloc==1) && (tcd_tcp->rates[layno]>0)) || ((cp->m_specific_param.m_enc.m_fixed_quality==1) && (tcd_tcp->distoratio[layno]>0))) {
|
||||
if ( ((cp->m_specific_param.m_enc.m_disto_alloc==1) && (tcd_tcp->rates[layno]>0.0f)) || ((cp->m_specific_param.m_enc.m_fixed_quality==1) && (tcd_tcp->distoratio[layno]>0.0))) {
|
||||
opj_t2_t*t2 = opj_t2_create(tcd->image, cp);
|
||||
OPJ_FLOAT64 thresh = 0;
|
||||
|
||||
@ -559,19 +558,13 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
||||
}
|
||||
}
|
||||
|
||||
success = OPJ_TRUE;
|
||||
goodthresh = stable_thresh == 0? thresh : stable_thresh;
|
||||
|
||||
opj_t2_destroy(t2);
|
||||
} else {
|
||||
success = OPJ_TRUE;
|
||||
goodthresh = min;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if(cstr_info) { /* Threshold for Marcela Index */
|
||||
cstr_info->tile[tcd->tcd_tileno].thresh[layno] = goodthresh;
|
||||
}
|
||||
@ -587,7 +580,8 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
|
||||
|
||||
OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
||||
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->cp = p_cp;
|
||||
@ -604,6 +598,7 @@ OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
||||
|
||||
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->thread_pool = p_tp;
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
@ -703,9 +698,20 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
l_tx0 = l_cp->tx0 + p * l_cp->tdx; /* can't be greater than l_image->x1 so won't overflow */
|
||||
l_tile->x0 = (OPJ_INT32)opj_uint_max(l_tx0, l_image->x0);
|
||||
l_tile->x1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_tx0, l_cp->tdx), l_image->x1);
|
||||
/* all those OPJ_UINT32 are casted to OPJ_INT32, let's do some sanity check */
|
||||
if ((l_tile->x0 < 0) || (l_tile->x1 <= l_tile->x0)) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Tile X coordinates are not supported\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_ty0 = l_cp->ty0 + q * l_cp->tdy; /* can't be greater than l_image->y1 so won't overflow */
|
||||
l_tile->y0 = (OPJ_INT32)opj_uint_max(l_ty0, l_image->y0);
|
||||
l_tile->y1 = (OPJ_INT32)opj_uint_min(opj_uint_adds(l_ty0, l_cp->tdy), l_image->y1);
|
||||
/* all those OPJ_UINT32 are casted to OPJ_INT32, let's do some sanity check */
|
||||
if ((l_tile->y0 < 0) || (l_tile->y1 <= l_tile->y0)) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Tile Y coordinates are not supported\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* testcase 1888.pdf.asan.35.988 */
|
||||
if (l_tccp->numresolutions == 0) {
|
||||
@ -727,7 +733,8 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
|
||||
/* compute l_data_size with overflow check */
|
||||
l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
|
||||
if ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0)) {
|
||||
/* issue 733, l_data_size == 0U, probably something wrong should be checked before getting here */
|
||||
if ((l_data_size > 0U) && ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0))) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
@ -778,7 +785,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
l_tilec->resolutions_size = l_data_size;
|
||||
}
|
||||
|
||||
l_level_no = l_tilec->numresolutions - 1;
|
||||
l_level_no = l_tilec->numresolutions;
|
||||
l_res = l_tilec->resolutions;
|
||||
l_step_size = l_tccp->stepsizes;
|
||||
if (l_tccp->qmfbid == 0) {
|
||||
@ -795,6 +802,8 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
OPJ_UINT32 cbgwidthexpn, cbgheightexpn;
|
||||
OPJ_UINT32 cblkwidthexpn, cblkheightexpn;
|
||||
|
||||
--l_level_no;
|
||||
|
||||
/* border for each resolution level (global) */
|
||||
l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
|
||||
l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
|
||||
@ -812,12 +821,22 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
l_br_prc_y_end = opj_int_ceildivpow2(l_res->y1, (OPJ_INT32)l_pdy) << l_pdy;
|
||||
/*fprintf(stderr, "\t\t\tprc_x_start=%d, prc_y_start=%d, br_prc_x_end=%d, br_prc_y_end=%d \n", l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end ,l_br_prc_y_end );*/
|
||||
|
||||
l_res->pw = (l_res->x0 == l_res->x1) ? 0 : (OPJ_UINT32)((l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);
|
||||
l_res->ph = (l_res->y0 == l_res->y1) ? 0 : (OPJ_UINT32)((l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
|
||||
l_res->pw = (l_res->x0 == l_res->x1) ? 0U : (OPJ_UINT32)((l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx);
|
||||
l_res->ph = (l_res->y0 == l_res->y1) ? 0U : (OPJ_UINT32)((l_br_prc_y_end - l_tl_prc_y_start) >> l_pdy);
|
||||
/*fprintf(stderr, "\t\t\tres_pw=%d, res_ph=%d\n", l_res->pw, l_res->ph );*/
|
||||
|
||||
|
||||
if ((l_res->pw != 0U) && ((((OPJ_UINT32)-1) / l_res->pw) < l_res->ph)) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_nb_precincts = l_res->pw * l_res->ph;
|
||||
|
||||
if ((((OPJ_UINT32)-1) / (OPJ_UINT32)sizeof(opj_tcd_precinct_t)) < l_nb_precincts) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_nb_precinct_size = l_nb_precincts * (OPJ_UINT32)sizeof(opj_tcd_precinct_t);
|
||||
|
||||
if (resno == 0) {
|
||||
tlcbgxstart = l_tl_prc_x_start;
|
||||
tlcbgystart = l_tl_prc_y_start;
|
||||
@ -874,6 +893,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
if (!l_band->precincts && (l_nb_precincts > 0U)) {
|
||||
l_band->precincts = (opj_tcd_precinct_t *) opj_malloc( /*3 * */ l_nb_precinct_size);
|
||||
if (! l_band->precincts) {
|
||||
opj_event_msg(manager, EVT_ERROR, "Not enough memory to handle band precints\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size); */
|
||||
@ -1024,7 +1044,6 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
|
||||
++l_step_size;
|
||||
} /* bandno */
|
||||
++l_res;
|
||||
--l_level_no;
|
||||
} /* resno */
|
||||
++l_tccp;
|
||||
++l_tilec;
|
||||
@ -1571,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 )
|
||||
{
|
||||
OPJ_UINT32 compno;
|
||||
opj_t1_t * l_t1;
|
||||
opj_tcd_tile_t * l_tile = p_tcd->tcd_image->tiles;
|
||||
opj_tcd_tilecomp_t* l_tile_comp = l_tile->comps;
|
||||
opj_tccp_t * l_tccp = p_tcd->tcp->tccps;
|
||||
|
||||
|
||||
l_t1 = opj_t1_create(OPJ_FALSE);
|
||||
if (l_t1 == 00) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
volatile OPJ_BOOL ret = OPJ_TRUE;
|
||||
|
||||
for (compno = 0; compno < l_tile->numcomps; ++compno) {
|
||||
/* The +3 is headroom required by the vectorized DWT */
|
||||
if (OPJ_FALSE == opj_t1_decode_cblks(l_t1, l_tile_comp, l_tccp)) {
|
||||
opj_t1_destroy(l_t1);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
opj_t1_decode_cblks(p_tcd->thread_pool, &ret, l_tile_comp, l_tccp);
|
||||
if( !ret )
|
||||
break;
|
||||
++l_tile_comp;
|
||||
++l_tccp;
|
||||
}
|
||||
|
||||
opj_t1_destroy(l_t1);
|
||||
opj_thread_pool_wait_completion(p_tcd->thread_pool, 0);
|
||||
|
||||
return OPJ_TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -1621,7 +1632,7 @@ static OPJ_BOOL opj_tcd_dwt_decode ( opj_tcd_t *p_tcd )
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1911,7 +1922,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd )
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < l_nb_elem; ++i) {
|
||||
*l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) << 11 ;
|
||||
*l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) * (1 << 11);
|
||||
++l_current_ptr;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ typedef struct opj_tcd_pass {
|
||||
OPJ_UINT32 rate;
|
||||
OPJ_FLOAT64 distortiondec;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_UINT32 term : 1;
|
||||
OPJ_BITFIELD term : 1;
|
||||
} opj_tcd_pass_t;
|
||||
|
||||
/**
|
||||
@ -219,7 +219,9 @@ typedef struct opj_tcd
|
||||
/** current encoded/decoded tile */
|
||||
OPJ_UINT32 tcd_tileno;
|
||||
/** 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;
|
||||
|
||||
/** @name Exported functions */
|
||||
@ -249,12 +251,14 @@ void opj_tcd_destroy(opj_tcd_t *tcd);
|
||||
* @param p_tcd TCD handle.
|
||||
* @param p_image raw image.
|
||||
* @param p_cp coding parameters.
|
||||
* @param p_tp thread pool
|
||||
*
|
||||
* @return true if the encoding values could be set (false otherwise).
|
||||
*/
|
||||
OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
||||
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.
|
||||
|
@ -49,7 +49,9 @@ int opj_write_thix( int coff, opj_codestream_info_t cstr_info, opj_stream_privat
|
||||
|
||||
lenp = 0;
|
||||
box = (opj_jp2_box_t *)opj_calloc( (size_t)(cstr_info.tw*cstr_info.th), sizeof(opj_jp2_box_t));
|
||||
|
||||
if(box == NULL){
|
||||
return 0;
|
||||
}
|
||||
for ( i = 0; i < 2 ; i++ ){
|
||||
if (i)
|
||||
opj_stream_seek( cio, lenp, p_manager);
|
||||
|
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
|
@ -5,9 +5,9 @@ include_directories(
|
||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||
)
|
||||
|
||||
SET(OPENJP3D_LIBRARY_NAME openjp3d)
|
||||
set(OPENJP3D_LIBRARY_NAME openjp3d)
|
||||
# Defines the source code for the library
|
||||
SET(OPENJP3D_SRCS
|
||||
set(OPENJP3D_SRCS
|
||||
bio.c cio.c dwt.c event.c jp3d.c jp3d_lib.c mct.c mqc.c openjp3d.c
|
||||
pi.c raw.c t1.c t1_3d.c t2.c tcd.c tgt.c volume.c
|
||||
)
|
||||
@ -34,7 +34,7 @@ endif()
|
||||
# Install library
|
||||
install(TARGETS ${OPENJP3D_LIBRARY_NAME}
|
||||
EXPORT OpenJP3DTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}
|
||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}
|
||||
COMPONENT Libraries
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, Mónica Díez, LPI-UVA, Spain
|
||||
* Copyright (c) 2006, Mónica Díez, LPI-UVA, Spain
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -1389,7 +1389,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_volume_i
|
||||
/* ----------------------------------------------------------------------- */
|
||||
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_volume_info_t * volume_info) {
|
||||
int compno;
|
||||
int l, i, npck = 0;
|
||||
int l = 0, i, npck = 0;
|
||||
double encoding_time;
|
||||
|
||||
opj_tcd_tile_t *tile = NULL;
|
||||
|
@ -36,6 +36,7 @@ set(OPENJPIP_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/opj_malloc.c
|
||||
)
|
||||
|
||||
set(SERVER_SRCS
|
||||
|
@ -117,6 +117,7 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
||||
|
||||
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
|
||||
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
|
||||
memset(&COD, 0, sizeof(COD));
|
||||
return COD;
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ void enqueue_allprecincts( int tile_id, int level, int lastcomp, OPJ_BOOL *comps
|
||||
OPJ_BOOL enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
int i;
|
||||
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
||||
for( i=0; i<MAX_NUMOFBOX && query_param.box_type[i][0]!=0; i++){
|
||||
if( query_param.box_type[i][0] == '*'){
|
||||
fprintf( FCGI_stdout, "Status: 501\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: metareq with all box-property * not implemented\r\n");
|
||||
|
@ -9,7 +9,7 @@ Name: openjpip
|
||||
Description: JPEG2000 Interactivity tools, APIs and protocols (Part 9)
|
||||
URL: http://www.openjpeg.org/
|
||||
Version: @OPENJPEG_VERSION@
|
||||
Requires: openjp2
|
||||
Requires: libopenjp2
|
||||
Libs: -L${libdir} -lopenjpip
|
||||
Libs.private: -lm -lcurl -lfcgi -lpthread
|
||||
Cflags: -I${includedir}
|
||||
|
@ -264,7 +264,7 @@ void print_queryparam( query_param_t query_param)
|
||||
}
|
||||
|
||||
fprintf( logstream, "\t req-box-prop\n");
|
||||
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
||||
for( i=0; i<MAX_NUMOFBOX && query_param.box_type[i][0]!=0; i++){
|
||||
fprintf( logstream, "\t\t box_type: %.4s limit: %d w:%d s:%d g:%d a:%d priority:%d\n", query_param.box_type[i], query_param.limit[i], query_param.w[i], query_param.s[i], query_param.g[i], query_param.a[i], query_param.priority[i]);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ Name: openjpwl
|
||||
Description: JPEG2000 Wireless library (Part 11)
|
||||
URL: http://www.openjpeg.org/
|
||||
Version: @OPENJPEG_VERSION@
|
||||
Requires: openjp2
|
||||
Requires: libopenjp2
|
||||
Libs: -L${libdir} -lopenjpwl
|
||||
Libs.private: -lm
|
||||
Cflags: -I${includedir}
|
||||
|
@ -53,12 +53,12 @@ endif()
|
||||
# Install library
|
||||
install(TARGETS ${OPENMJ2_LIBRARY_NAME}
|
||||
EXPORT OpenMJ2Targets
|
||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}
|
||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}
|
||||
COMPONENT Libraries
|
||||
)
|
||||
|
||||
# Install includes files
|
||||
#INSTALL(FILES mj2.h
|
||||
# DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/${subdir}
|
||||
#install(FILES mj2.h
|
||||
# DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/${subdir}
|
||||
# COMPONENT Headers
|
||||
#)
|
||||
|
@ -1,165 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||
* 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 __OPJ_MALLOC_H
|
||||
#define __OPJ_MALLOC_H
|
||||
/**
|
||||
@file opj_malloc.h
|
||||
@brief Internal functions
|
||||
|
||||
The functions in opj_malloc.h are internal utilities used for memory management.
|
||||
*/
|
||||
|
||||
/** @defgroup MISC MISC - Miscellaneous internal functions */
|
||||
/*@{*/
|
||||
|
||||
/** @name Exported functions */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
Allocate an uninitialized memory block
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_malloc(size_t size);
|
||||
#else
|
||||
#define opj_malloc(size) malloc(size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate a memory block with elements initialized to 0
|
||||
@param num Blocks to allocate
|
||||
@param size Bytes per block to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
|
||||
#else
|
||||
#define opj_calloc(num, size) calloc(num, size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate memory aligned to a 16 byte boundary
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef _WIN32
|
||||
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
|
||||
#ifdef __GNUC__
|
||||
#include <mm_malloc.h>
|
||||
#define HAVE_MM_MALLOC
|
||||
#else /* MSVC, Intel C++ */
|
||||
#include <malloc.h>
|
||||
#ifdef _mm_malloc
|
||||
#define HAVE_MM_MALLOC
|
||||
#endif
|
||||
#endif
|
||||
#else /* Not _WIN32 */
|
||||
#if defined(__sun)
|
||||
#define HAVE_MEMALIGN
|
||||
#elif defined(__FreeBSD__)
|
||||
#define HAVE_POSIX_MEMALIGN
|
||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
|
||||
#define HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define opj_aligned_malloc(size) malloc(size)
|
||||
#define opj_aligned_free(m) free(m)
|
||||
|
||||
#ifdef HAVE_MM_MALLOC
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) _mm_free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMALIGN
|
||||
extern void* memalign(size_t, size_t);
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) memalign(16, (size))
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
#undef opj_aligned_malloc
|
||||
extern int posix_memalign(void**, size_t, size_t);
|
||||
|
||||
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
|
||||
void* mem = NULL;
|
||||
posix_memalign(&mem, 16, size);
|
||||
return mem;
|
||||
}
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) opj_malloc(size)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) opj_free(m)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Reallocate memory blocks.
|
||||
@param m Pointer to previously allocated memory block
|
||||
@param s New size in bytes
|
||||
@return Returns a void pointer to the reallocated (and possibly moved) memory block
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
|
||||
#else
|
||||
#define opj_realloc(m, s) realloc(m, s)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Deallocates or frees a memory block.
|
||||
@param m Previously allocated memory block to be freed
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void OPJ_CALLCONV opj_free(void * m);
|
||||
#else
|
||||
#define opj_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* __OPJ_MALLOC_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||
* 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 __OPJ_MALLOC_H
|
||||
#define __OPJ_MALLOC_H
|
||||
/**
|
||||
@file opj_malloc.h
|
||||
@brief Internal functions
|
||||
|
||||
The functions in opj_malloc.h are internal utilities used for memory management.
|
||||
*/
|
||||
|
||||
/** @defgroup MISC MISC - Miscellaneous internal functions */
|
||||
/*@{*/
|
||||
|
||||
/** @name Exported functions */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
Allocate an uninitialized memory block
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_malloc(size_t size);
|
||||
#else
|
||||
#define opj_malloc(size) malloc(size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate a memory block with elements initialized to 0
|
||||
@param num Blocks to allocate
|
||||
@param size Bytes per block to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
|
||||
#else
|
||||
#define opj_calloc(num, size) calloc(num, size)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Allocate memory aligned to a 16 byte boundary
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef _WIN32
|
||||
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
|
||||
#ifdef __GNUC__
|
||||
#include <mm_malloc.h>
|
||||
#define HAVE_MM_MALLOC
|
||||
#else /* MSVC, Intel C++ */
|
||||
#include <malloc.h>
|
||||
#ifdef _mm_malloc
|
||||
#define HAVE_MM_MALLOC
|
||||
#endif
|
||||
#endif
|
||||
#else /* Not _WIN32 */
|
||||
#if defined(__sun)
|
||||
#define HAVE_MEMALIGN
|
||||
#elif defined(__FreeBSD__)
|
||||
#define HAVE_POSIX_MEMALIGN
|
||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
|
||||
#define HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define opj_aligned_malloc(size) malloc(size)
|
||||
#define opj_aligned_free(m) free(m)
|
||||
|
||||
#ifdef HAVE_MM_MALLOC
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) _mm_free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMALIGN
|
||||
extern void* memalign(size_t, size_t);
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) memalign(16, (size))
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
#undef opj_aligned_malloc
|
||||
extern int posix_memalign(void**, size_t, size_t);
|
||||
|
||||
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
|
||||
void* mem = NULL;
|
||||
posix_memalign(&mem, 16, size);
|
||||
return mem;
|
||||
}
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) opj_malloc(size)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) opj_free(m)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Reallocate memory blocks.
|
||||
@param m Pointer to previously allocated memory block
|
||||
@param s New size in bytes
|
||||
@return Returns a void pointer to the reallocated (and possibly moved) memory block
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
|
||||
#else
|
||||
#define opj_realloc(m, s) realloc(m, s)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Deallocates or frees a memory block.
|
||||
@param m Previously allocated memory block to be freed
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void OPJ_CALLCONV opj_free(void * m);
|
||||
#else
|
||||
#define opj_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* __OPJ_MALLOC_H */
|
||||
|
||||
|
@ -80,6 +80,8 @@ set_property(TEST rta4 APPEND PROPERTY DEPENDS tte4)
|
||||
add_test(NAME rta5 COMMAND j2k_random_tile_access tte5.j2k)
|
||||
set_property(TEST rta5 APPEND PROPERTY DEPENDS tte5)
|
||||
|
||||
add_executable(include_openjpeg include_openjpeg.c)
|
||||
|
||||
# No image send to the dashboard if lib PNG is not available.
|
||||
if(NOT OPJ_HAVE_LIBPNG)
|
||||
message(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)")
|
||||
|
@ -118,10 +118,10 @@ int main(int argc, char **argv)
|
||||
test_cmp_parameters inParam;
|
||||
FILE *fbase=NULL, *ftest=NULL;
|
||||
int same = 0;
|
||||
char lbase[256];
|
||||
char strbase[256];
|
||||
char ltest[256];
|
||||
char strtest[256];
|
||||
char lbase[512];
|
||||
char strbase[512];
|
||||
char ltest[512];
|
||||
char strtest[512];
|
||||
|
||||
if( parse_cmdline_cmp(argc, argv, &inParam) == 1 )
|
||||
{
|
||||
@ -154,9 +154,9 @@ int main(int argc, char **argv)
|
||||
|
||||
while (fgets(lbase, sizeof(lbase), fbase) && fgets(ltest,sizeof(ltest),ftest))
|
||||
{
|
||||
int nbase = sscanf(lbase, "%255[^\r\n]", strbase);
|
||||
int ntest = sscanf(ltest, "%255[^\r\n]", strtest);
|
||||
assert( nbase != 255 && ntest != 255 );
|
||||
int nbase = sscanf(lbase, "%511[^\r\n]", strbase);
|
||||
int ntest = sscanf(ltest, "%511[^\r\n]", strtest);
|
||||
assert( nbase != 511 && ntest != 511 );
|
||||
if( nbase != 1 || ntest != 1 )
|
||||
{
|
||||
fprintf(stderr, "could not parse line from files\n" );
|
||||
|
@ -877,6 +877,8 @@ int main(int argc, char **argv)
|
||||
|
||||
printf("<DartMeasurement name=\"NumberOfPixelsWithDifferences_%d\" type=\"numeric/int\"> %d </DartMeasurement> \n", it_comp, nbPixelDiff);
|
||||
printf("<DartMeasurement name=\"ComponentError_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, sumDiff);
|
||||
printf("<DartMeasurement name=\"PEAK_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, PEAK);
|
||||
printf("<DartMeasurement name=\"MSE_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, MSE);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBPNG
|
||||
{
|
||||
|
9
tests/include_openjpeg.c
Normal file
9
tests/include_openjpeg.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <openjpeg.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
return 0;
|
||||
}
|
@ -37,7 +37,7 @@ set(BLACKLIST_JPEG2000_TMP
|
||||
#edf_c2_20.jp2 #looks ok as per kdu_jp2info
|
||||
edf_c2_1377017.jp2
|
||||
edf_c2_1002767.jp2
|
||||
#edf_c2_10025.jp2
|
||||
edf_c2_10025.jp2
|
||||
edf_c2_1000234.jp2
|
||||
edf_c2_225881.jp2
|
||||
edf_c2_1000671.jp2
|
||||
@ -46,15 +46,18 @@ set(BLACKLIST_JPEG2000_TMP
|
||||
edf_c2_101463.jp2
|
||||
edf_c2_1674177.jp2
|
||||
edf_c2_1673169.jp2
|
||||
issue418.jp2
|
||||
issue429.jp2
|
||||
issue427-null-image-size.jp2
|
||||
issue427-illegal-tile-offset.jp2
|
||||
issue495.jp2
|
||||
issue820.jp2
|
||||
)
|
||||
|
||||
# Define a list of file which should be gracefully rejected:
|
||||
set(BLACKLIST_JPEG2000
|
||||
${BLACKLIST_JPEG2000_TMP}
|
||||
broken1.jp2
|
||||
broken1.jp2
|
||||
broken2.jp2
|
||||
broken3.jp2
|
||||
broken4.jp2
|
||||
@ -339,7 +342,7 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST})
|
||||
NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-decode-ref)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# Test the encoded file is a valid JP2 file
|
||||
if (JPYLYZER_EXECUTABLE)
|
||||
if (${OUTPUT_FILENAME} MATCHES "\\.jp2$")
|
||||
@ -347,13 +350,13 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST})
|
||||
COMMAND ${JPYLYZER_EXECUTABLE}
|
||||
${OUTPUT_FILENAME}
|
||||
)
|
||||
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-jpylyser PROPERTIES
|
||||
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-jpylyser PROPERTIES
|
||||
DEPENDS NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-encode
|
||||
PASS_REGULAR_EXPRESSION "<isValidJP2>True</isValidJP2>"
|
||||
)
|
||||
endif()
|
||||
endif(JPYLYZER_EXECUTABLE)
|
||||
|
||||
|
||||
# If lossless compression (simple test is 4 arguments), decompress & compare
|
||||
list(LENGTH CMD_ARG_LIST_2 ARG_COUNT)
|
||||
if (ARG_COUNT EQUAL 4)
|
||||
@ -362,13 +365,13 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST})
|
||||
add_test(NAME NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode
|
||||
COMMAND opj_decompress -i ${OUTPUT_FILENAME} -o ${OUTPUT_FILENAME}.lossless.tif
|
||||
)
|
||||
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode PROPERTIES
|
||||
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode PROPERTIES
|
||||
DEPENDS NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-encode
|
||||
)
|
||||
add_test(NAME NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-compare
|
||||
COMMAND compare_images -b ${INPUT_FILENAME} -t ${OUTPUT_FILENAME}.lossless.tif -n 1 -d
|
||||
)
|
||||
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-compare PROPERTIES
|
||||
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-compare PROPERTIES
|
||||
DEPENDS NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode
|
||||
)
|
||||
endif()
|
||||
@ -400,7 +403,7 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST})
|
||||
-DOUTFILENAME:STRING=${OUTPUT_FILENAME}
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/checkmd5refs.cmake)
|
||||
|
||||
set_tests_properties(NR-DEC-${INPUT_FILENAME_NAME}-${IT_TEST_DEC}-decode-md5
|
||||
set_tests_properties(NR-DEC-${INPUT_FILENAME_NAME}-${IT_TEST_DEC}-decode-md5
|
||||
PROPERTIES DEPENDS NR-DEC-${INPUT_FILENAME_NAME}-${IT_TEST_DEC}-decode
|
||||
)
|
||||
|
||||
|
@ -43,11 +43,11 @@ file(READ ${REFFILE} variable)
|
||||
foreach(pgxfullpath ${globfiles})
|
||||
file(MD5 ${pgxfullpath} output)
|
||||
get_filename_component(pgxfile ${pgxfullpath} NAME)
|
||||
|
||||
|
||||
string(REGEX MATCH "[0-9a-f]+ ${pgxfile}" output_var "${variable}")
|
||||
|
||||
set(output "${output} ${pgxfile}")
|
||||
|
||||
|
||||
if("${output_var}" STREQUAL "${output}")
|
||||
message(STATUS "equal: [${output_var}] vs [${output}]")
|
||||
else()
|
||||
|
@ -21,15 +21,15 @@ cccccccccccccccccccccccccccccccc issue104_jpxstream.jp2_2.pgx
|
||||
c74edbb49e132b2cfc1eaf7908197b17 issue134.jp2_0.pgx
|
||||
16fe8ed450da10a6aaae4cf6f467fc21 issue134.jp2_1.pgx
|
||||
c6091c07bf0ff221008dfb60d893cdff issue134.jp2_2.pgx
|
||||
cccccccccccccccccccccccccccccccc issue135.j2k_0.pgx
|
||||
cccccccccccccccccccccccccccccccc issue135.j2k_1.pgx
|
||||
cccccccccccccccccccccccccccccccc issue135.j2k_2.pgx
|
||||
bee38bdc0dde1a891a8d9650f475db38 issue135.j2k_0.pgx
|
||||
dbabd772b1e53959e1e1c4bdf58e0108 issue135.j2k_1.pgx
|
||||
65d5ed69d3c994f33d3a9d649ec6f1da issue135.j2k_2.pgx
|
||||
aa7461b31e14641586803b23b7fb04f2 issue142.j2k_0.pgx
|
||||
a809006e7a0c1eed68bc86c96af43fe3 issue142.j2k_1.pgx
|
||||
74f7a7a194a74a947245b843c62c4054 issue142.j2k_2.pgx
|
||||
c44662b1f7fe01caa2ebf3ad62948e3e issue171.jp2_0.pgx
|
||||
f70e8a4e5dbefeb44d50edd79b6c4cf6 issue171.jp2_1.pgx
|
||||
18bc167a1c851db2fd9f8c7af3289134 issue171.jp2_2.pgx
|
||||
f9d1ada7f0f16c8c4f929217a1924416 issue171.jp2_0.pgx
|
||||
0d4a8507e226130bc44ef7de7e5539f6 issue171.jp2_1.pgx
|
||||
fde95f3c3bd8639b2258332eb6f658e4 issue171.jp2_2.pgx
|
||||
adda4f5e46845b96dd3df14a76aa7229 issue188_beach_64bitsbox.jp2_0.pgx
|
||||
90a9709c166019d1e101e7b96d257ed9 issue188_beach_64bitsbox.jp2_1.pgx
|
||||
37e23d2df06ee60bf0f9f5e1c16054d8 issue188_beach_64bitsbox.jp2_2.pgx
|
||||
@ -52,12 +52,12 @@ e58242abc2c6d44df187397c55e6fbff issue254.jp2_2.pgx
|
||||
ce4e556aaa0844b92a92c35c200fc43e j2k32.j2k_1.pgx
|
||||
ea926520f990640862f3fe6616097613 j2k32.j2k_2.pgx
|
||||
66b60e866991e03f9a2de18e80d3102b kakadu_v4-4_openjpegv2_broken.j2k_0.pgx
|
||||
12a8a4668315d9ae27969991251ce85f kodak_2layers_lrcp.j2c_0.pgx
|
||||
56d0b0c547d6d5bb12f0c36e88722b11 kodak_2layers_lrcp.j2c_1.pgx
|
||||
48ba092fb40090c160bbd08bdf7bdbf2 kodak_2layers_lrcp.j2c_2.pgx
|
||||
12a8a4668315d9ae27969991251ce85f kodak_2layers_lrcp-l2.j2c_0.pgx
|
||||
56d0b0c547d6d5bb12f0c36e88722b11 kodak_2layers_lrcp-l2.j2c_1.pgx
|
||||
48ba092fb40090c160bbd08bdf7bdbf2 kodak_2layers_lrcp-l2.j2c_2.pgx
|
||||
bee38bdc0dde1a891a8d9650f475db38 kodak_2layers_lrcp.j2c_0.pgx
|
||||
dbabd772b1e53959e1e1c4bdf58e0108 kodak_2layers_lrcp.j2c_1.pgx
|
||||
65d5ed69d3c994f33d3a9d649ec6f1da kodak_2layers_lrcp.j2c_2.pgx
|
||||
bee38bdc0dde1a891a8d9650f475db38 kodak_2layers_lrcp-l2.j2c_0.pgx
|
||||
dbabd772b1e53959e1e1c4bdf58e0108 kodak_2layers_lrcp-l2.j2c_1.pgx
|
||||
65d5ed69d3c994f33d3a9d649ec6f1da kodak_2layers_lrcp-l2.j2c_2.pgx
|
||||
05c062aca83d13b8095460f38a690a08 MarkerIsNotCompliant.j2k_0.pgx
|
||||
ff73d2bd32951d9e55b02186aac24aff Marrin.jp2_0.pgx
|
||||
55ce884dd2346af6a5172a434ee578fa Marrin.jp2_1.pgx
|
||||
@ -148,7 +148,7 @@ c494419005e8aae82f46d3f48da6caf1 p1_06.j2k.png
|
||||
6ae110e1fb5a869af3dbc5fbc735b0bd relax.jp2_0.pgx
|
||||
518a8f28dacc034982507f43763b88dd relax.jp2_1.pgx
|
||||
c678b04f4d3e59b9d66a8bce37c553c0 relax.jp2_2.pgx
|
||||
cdb1d69eb48ffd8545751326b86d9d7e test_lossless.j2k_0.pgx
|
||||
1090301e16fcfdecf3419bccad61cdeb test_lossless.j2k_0.pgx
|
||||
efc9c7f21a542a7888a9eeb73b0f7092 text_GBR.jp2_0.pgx
|
||||
54790b332b3dcbda28e1bcb31270b946 text_GBR.jp2_1.pgx
|
||||
d9bcbdc818febb8c0a6bc5f940a4ea85 text_GBR.jp2_2.pgx
|
||||
@ -163,7 +163,7 @@ a73bec4d6d82c8a64203e8fdf893b86d issue428.jp2_0.pgx
|
||||
8b96a253937c4c7dd6b41b4aa11367d9 issue414.jp2_2.pgx
|
||||
ec6886229ffaeaddfe22ce02b7a75e15 issue414.jp2_3.pgx
|
||||
6aa5c69c83d6f4d5d65968f34f9bc2a3 issue414.jp2_4.pgx
|
||||
00f34217ad2f88f4d4e1c5cd0d2c4329 issue399.j2k_0.pgx
|
||||
296038e047bb6aaf0e6652cb1b301e60 issue399.j2k_0.pgx
|
||||
d8fb69def2a48a3686483c4353544f4b issue411-ycc444.jp2_0.pgx
|
||||
d2911f75ed1758057f9b1bf26bcb2400 issue411-ycc444.jp2_1.pgx
|
||||
f7c23ee589ceda07ffb77a83018606cc issue411-ycc444.jp2_2.pgx
|
||||
@ -182,40 +182,68 @@ d33fb5dbddb9b9b4438eb51fa27445a3 issue495.jp2_0.pgx
|
||||
97da625d2f2d0b75bf891d8083ce8bfb issue495.jp2_2.pgx
|
||||
86729c5f2b74b2dfd42cb0d8e47aef79 a1_mono_tif-1.tif
|
||||
fa9b7b896536b25a7a1d8eeeacb59141 a1_mono_tif-10.tif
|
||||
e1f194f69d1c58ce8bed62cd4f1d5b6a a1_mono_tif-11.tif
|
||||
b0ee13aa90ca4421e09a3b7b41f410c0 a1_mono_tif-12.tif
|
||||
de53251a33356e206a793fbdbaf90db2 a1_mono_tif-13.tif
|
||||
4699894fedd3758727d8288cd7adb56c a1_mono_tif-14.tif
|
||||
012958af4207f4a779c0cdc9e18bc9be a1_mono_tif-15.tif
|
||||
4ad682c58e63d3223914c10a6656c8ae a1_mono_tif-16.tif
|
||||
22c2fa09a4d7b9fade6a3cddc6c6a4dc a1_mono_tif-2.tif
|
||||
7aea003d047d6c26475d0d257a0cfdfc a1_mono_tif-3.tif
|
||||
996c5e67a663218be90e86bff8ecad89 a1_mono_tif-4.tif
|
||||
0489a5d490588fa603a8e59af60ef8fc a1_mono_tif-5.tif
|
||||
7f451a5ac89915c5cdc023fd8c813a3c a1_mono_tif-6.tif
|
||||
e164a6c0219737ee05a3d55d6e3a3104 a1_mono_tif-7.tif
|
||||
c3ebfcf478b1c4fc786748813f2b5d53 a1_mono_tif-8.tif
|
||||
67adb084f1fe234f240a1d0b2698507e a1_mono_tif-9.tif
|
||||
31650ec40241737634179fff6ad306f8 basn4a08_tif-1.tif
|
||||
abf884080bcfbf58c044a9d86bfa5e5d basn4a08_tif-10.tif
|
||||
b0d82c12aa2c9b3ecd96c6a5b5663a8c basn4a08_tif-11.tif
|
||||
916d97c098d9792993cc91fee4a83f77 basn4a08_tif-12.tif
|
||||
90cabbb0f401b75dcfa64e4fbb987020 basn4a08_tif-13.tif
|
||||
57643174986481d336db6ddf04b970df basn4a08_tif-14.tif
|
||||
3cbf7868617a0dfdbeddd5c50ea96b31 basn4a08_tif-15.tif
|
||||
fb5cf848d63c61dc485c87c9246ee9c7 basn4a08_tif-16.tif
|
||||
5d7b01d98c82ad563bb28c2d83484a2a basn4a08_tif-2.tif
|
||||
7928de544e7d9731572a625beeb2b3ee basn4a08_tif-3.tif
|
||||
2401cebbb1d5494fcbe0d899484c342d basn4a08_tif-4.tif
|
||||
05ea9dfd48a6cd613bf935394988ec38 basn4a08_tif-5.tif
|
||||
6dbeb5b708bbde76e204c0887da61f6b basn4a08_tif-6.tif
|
||||
18a59ac6036ee64e92af19b7e3cd3d64 basn4a08_tif-7.tif
|
||||
dc40cc1da6de28e7e973c8ba796ca189 basn4a08_tif-8.tif
|
||||
824b776a5aa3459b77894b5f77621311 basn4a08_tif-9.tif
|
||||
59e32c45591fd3bb44fe99381a116ba1 basn6a08_tif-1.tif
|
||||
630e6fb6deba0b3efd93b610561d607a basn6a08_tif-10.tif
|
||||
5419fec92f0e0e5907d838dacf9712b4 basn6a08_tif-11.tif
|
||||
765555e75e59de27f7b2177d04f36bc1 basn6a08_tif-12.tif
|
||||
7d20d3e026fc1ac25be16dd44e9fb2e5 basn6a08_tif-13.tif
|
||||
62384c112d5fe40aefd0a9b0b9a4bcc6 basn6a08_tif-14.tif
|
||||
325de66e18e133f2ad865fc1faa20439 basn6a08_tif-15.tif
|
||||
d725d41557658a28ab31dff74e2467fa basn6a08_tif-16.tif
|
||||
96d91df6b10e866ea26ebbf0b8ddc7da basn6a08_tif-2.tif
|
||||
36690c1fe565b6efc229f5c7e486de31 basn6a08_tif-3.tif
|
||||
a324032339808d5fe85d6e354f14c183 basn6a08_tif-4.tif
|
||||
64dfb6af672ea8e890e24cfb208c6755 basn6a08_tif-5.tif
|
||||
d60864a6a5c8a49a202d98ae6f5165c7 basn6a08_tif-6.tif
|
||||
086fd12fec963995fe2e405dcef7e477 basn6a08_tif-7.tif
|
||||
c3e93f61125f82a9832d0b9440468034 basn6a08_tif-8.tif
|
||||
a9723dcc0732e74c9e8cd2bf93474a7d basn6a08_tif-9.tif
|
||||
cfe04d15cf9d615fc36357dcb3b3956b p0_14_tif-1.tif
|
||||
9ad87e7fddc77ac85e2e92509bee2365 p0_14_tif-10.tif
|
||||
f144e26d6d5aa24d98f0415f10751025 p0_14_tif-11.tif
|
||||
38e67f9d573e61166761d5eee0104448 p0_14_tif-12.tif
|
||||
4e804903537e4c52a7e4c15bd74eb15c p0_14_tif-13.tif
|
||||
77486f0468694b94290d0b55361498a0 p0_14_tif-14.tif
|
||||
2aa3211823a8ee41cc5061f401dfd52d p0_14_tif-15.tif
|
||||
51be675689949dd08b6ee1427af3eb4a p0_14_tif-16.tif
|
||||
3e34e94bd8f7380c8d159676fee9ea57 p0_14_tif-2.tif
|
||||
f623c6b98711ba8582f2b60620c6494a p0_14_tif-3.tif
|
||||
b6f71c941e3a5b8d2547792ccec58d54 p0_14_tif-4.tif
|
||||
5a8498d473cc57318ab9d216fdc5dcc9 p0_14_tif-5.tif
|
||||
81fcdd90917efb95aed94c6522d1c188 p0_14_tif-6.tif
|
||||
951c99efbd922d8f3feb015e9ef8e350 p0_14_tif-7.tif
|
||||
6808377b760b4ef3559ba8b14ed9b91a p0_14_tif-8.tif
|
||||
96aa7dafa873d0ce33f84bb1ff78fa9b p0_14_tif-9.tif
|
||||
dd15b3d487d36a3682be0679300a4319 issue235.jp2_0.pgx
|
||||
b9cd6dc76b141fb1fec15f50c1f70e01 issue235.jp2_1.pgx
|
||||
3edef2ae197ef30b08deda1b28825399 issue235.jp2_2.pgx
|
||||
@ -256,17 +284,19 @@ fc2844a9f3c8e924e349180ba9e122dd p0_14_png-2.png
|
||||
0c1cc85c051dd95394d06103c8d9bbef p0_14_png-6.png
|
||||
230e4968cb445b222ee2095014ba1d26 p0_14_png-8.png
|
||||
5a6131ad9ea5d191ffcdf6435be89cb4 v4dwt_interleave_h.gsr105.j2k_0.pgx
|
||||
4426ed46f75a45782c551d82818b9e60 dwt_interleave_h.gsr105.jp2_0.pgx
|
||||
382e7297e062d729a7a7726e964f1a0a dwt_interleave_h.gsr105.jp2_1.pgx
|
||||
64c1027db97421e348f823178b5d9c4b dwt_interleave_h.gsr105.jp2_2.pgx
|
||||
65e41ed91283b5e2f0c79ee1c867a86c dwt_interleave_h.gsr105.jp2_0.pgx
|
||||
8d7685f1569d446787476c0a56c93750 dwt_interleave_h.gsr105.jp2_1.pgx
|
||||
ddfff2ce2df4a9102518c92a362e6d25 dwt_interleave_h.gsr105.jp2_2.pgx
|
||||
63bf755af5a1f8a478d65079dc7c8964 issue205-tif.jp2.tif
|
||||
b01ed87dbac424bc820b2ac590e4884e issue236-ESYCC-CDEF.jp2_0.pgx
|
||||
2635cc00b1e18ef11adcba09e845d459 issue236-ESYCC-CDEF.jp2_1.pgx
|
||||
f9c95d0aec2f6e7b814fa1d09edcdbda issue236-ESYCC-CDEF.jp2_2.pgx
|
||||
5f0c1d5c5127c1eabb86a5e0112f139b issue559-eci-090-CIELab.jp2_0.pgx
|
||||
cdae87485eaada56be3671eec39452e6 issue559-eci-090-CIELab.jp2_1.pgx
|
||||
e163102afcc857cf001337178241f518 issue559-eci-090-CIELab.jp2_2.pgx
|
||||
b004b2e08b0dfb217c131b353cf157eb issue559-eci-091-CIELab.jp2_0.pgx
|
||||
2400da6b8ed6b1747b9913af544580f9 issue559-eci-091-CIELab.jp2_1.pgx
|
||||
cf73dda887967928dbcf5cc87ab204cc issue559-eci-091-CIELab.jp2_2.pgx
|
||||
4c3a5c669aaaa330134c7014b26ed06f issue559-eci-090-CIELab.jp2_0.pgx
|
||||
d6698c71d1ed3861edaadc430af928eb issue559-eci-090-CIELab.jp2_1.pgx
|
||||
04f3ec1fea6049769c43b1ac3b05794e issue559-eci-090-CIELab.jp2_2.pgx
|
||||
a190e10941e6145e69816c909f832c1a issue559-eci-091-CIELab.jp2_0.pgx
|
||||
3fccf3c7ecd3b9de46b94b53a1fa0362 issue559-eci-091-CIELab.jp2_1.pgx
|
||||
f3081c8e9e9a175f223382a7443b480f issue559-eci-091-CIELab.jp2_2.pgx
|
||||
3bf91c974abc17e520c6a5efa883a58a issue653-zero-unknownbox.jp2.png
|
||||
8d7a866d29d5c68dc540b0f0011959a5 issue726.png
|
||||
3bf91c974abc17e520c6a5efa883a58a issue818.png
|
||||
|
@ -137,6 +137,18 @@ opj_compress -i @INPUT_NR_PATH@/pngsuite/ftp1n3p08.png -o @TEMP_PATH@/ftp1n3p08.
|
||||
# issue 571 Lossless is not lossless on linux x86
|
||||
opj_compress -i @INPUT_NR_PATH@/issue571.tif -o @TEMP_PATH@/issue571.tif.j2k
|
||||
|
||||
# issue 729 Allow to read 3/5/7/9/11/13/15 bpp tif files
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-03.tif -o @TEMP_PATH@/flower-minisblack-03.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-05.tif -o @TEMP_PATH@/flower-minisblack-05.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-07.tif -o @TEMP_PATH@/flower-minisblack-07.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-09.tif -o @TEMP_PATH@/flower-minisblack-09.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-11.tif -o @TEMP_PATH@/flower-minisblack-11.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-13.tif -o @TEMP_PATH@/flower-minisblack-13.tif.jp2
|
||||
opj_compress -i @INPUT_NR_PATH@/flower-minisblack-15.tif -o @TEMP_PATH@/flower-minisblack-15.tif.jp2
|
||||
|
||||
# issue 843 Crash with invalid ppm file
|
||||
!opj_compress -i @INPUT_NR_PATH@/issue843.ppm -o @TEMP_PATH@/issue843.ppm.jp2
|
||||
|
||||
# DECODER TEST SUITE
|
||||
opj_decompress -i @INPUT_NR_PATH@/Bretagne2.j2k -o @TEMP_PATH@/Bretagne2.j2k.pgx
|
||||
opj_decompress -i @INPUT_NR_PATH@/_00042.j2k -o @TEMP_PATH@/_00042.j2k.pgx
|
||||
@ -328,7 +340,7 @@ opj_decompress -i @INPUT_NR_PATH@/issue458.jp2 -o @TEMP_PATH@/issue458.jp2.pgx
|
||||
# issue 475 Invalid number of layers
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue475.jp2 -o @TEMP_PATH@/issue475.jp2.pgx
|
||||
# issue 495 Overflow op_image_comp_header_updat
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue495.jp2 -o @TEMP_PATH@/issue495.jp2.pgx
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue495.jp2 -o @TEMP_PATH@/issue495.jp2.pgx
|
||||
|
||||
|
||||
# decode with specific area
|
||||
@ -508,3 +520,57 @@ opj_decompress -i @INPUT_NR_PATH@/issue559-eci-091-CIELab.jp2 -o @TEMP_PATH@/iss
|
||||
|
||||
# issue 653 Last box of undefined size byg
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue653-zero-unknownbox.jp2 -o @TEMP_PATH@/issue653-zero-unknownbox.jp2.png -p 8S
|
||||
|
||||
# issue 729 decompress 3/5/7/9/11/13/15 bits precision to tiff
|
||||
# GRAYSCALE
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/a1_mono.j2c -o @TEMP_PATH@/a1_mono_tif-15.tif -p 15S
|
||||
# GRAYSCALE ALPHA
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn4a08.jp2 -o @TEMP_PATH@/basn4a08_tif-15.tif -p 15S
|
||||
# RGB
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_CONF_PATH@/p0_14.j2k -o @TEMP_PATH@/p0_14_tif-15.tif -p 15S
|
||||
# RGBA
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-3.tif -p 3S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-5.tif -p 5S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-7.tif -p 7S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-9.tif -p 9S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-11.tif -p 11S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-13.tif -p 13S
|
||||
opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-15.tif -p 15S
|
||||
|
||||
# issue 725
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue725.jp2 -o @TEMP_PATH@/issue725.png
|
||||
# issue 726
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue726.j2k -o @TEMP_PATH@/issue726.png
|
||||
# issue 733
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue733.jp2 -o @TEMP_PATH@/issue733.png
|
||||
# issue 774
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue774.jp2 -o @TEMP_PATH@/issue774.png
|
||||
# issue 775
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue775.j2k -o @TEMP_PATH@/issue775.png
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue775-2.j2k -o @TEMP_PATH@/issue775-2.png
|
||||
# issue 818
|
||||
opj_decompress -i @INPUT_NR_PATH@/issue818.jp2 -o @TEMP_PATH@/issue818.png
|
||||
# issue 823
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue823.jp2 -o @TEMP_PATH@/issue823.png
|
||||
# issue 826
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue826.jp2 -o @TEMP_PATH@/issue826.png
|
||||
# issue 820
|
||||
!opj_decompress -i @INPUT_NR_PATH@/issue820.jp2 -o @TEMP_PATH@/issue820.png
|
||||
|
@ -178,7 +178,7 @@ int main (int argc, char *argv[])
|
||||
int da_y0=0;
|
||||
int da_x1=1000;
|
||||
int da_y1=1000;
|
||||
char input_file[64];
|
||||
const char *input_file;
|
||||
|
||||
/* should be test_tile_decoder 0 0 1000 1000 tte1.j2k */
|
||||
if( argc == 6 )
|
||||
@ -187,7 +187,7 @@ int main (int argc, char *argv[])
|
||||
da_y0=atoi(argv[2]);
|
||||
da_x1=atoi(argv[3]);
|
||||
da_y1=atoi(argv[4]);
|
||||
strcpy(input_file,argv[5]);
|
||||
input_file = argv[5];
|
||||
|
||||
}
|
||||
else
|
||||
@ -196,7 +196,7 @@ int main (int argc, char *argv[])
|
||||
da_y0=0;
|
||||
da_x1=1000;
|
||||
da_y1=1000;
|
||||
strcpy(input_file,"test.j2k");
|
||||
input_file = "test.j2k";
|
||||
}
|
||||
|
||||
if (! l_data) {
|
||||
|
@ -69,7 +69,7 @@ int main (int argc, char *argv[])
|
||||
opj_stream_t * l_stream;
|
||||
OPJ_UINT32 l_nb_tiles;
|
||||
OPJ_UINT32 l_data_size;
|
||||
unsigned char len;
|
||||
size_t len;
|
||||
|
||||
#ifdef USING_MCT
|
||||
const OPJ_FLOAT32 l_mct [] =
|
||||
@ -96,7 +96,7 @@ int main (int argc, char *argv[])
|
||||
int tile_height;
|
||||
int comp_prec;
|
||||
int irreversible;
|
||||
char output_file[64];
|
||||
const char *output_file;
|
||||
|
||||
/* should be test_tile_encoder 3 2000 2000 1000 1000 8 tte1.j2k */
|
||||
if( argc == 9 )
|
||||
@ -108,7 +108,7 @@ int main (int argc, char *argv[])
|
||||
tile_height = atoi( argv[5] );
|
||||
comp_prec = atoi( argv[6] );
|
||||
irreversible = atoi( argv[7] );
|
||||
strcpy(output_file, argv[8] );
|
||||
output_file = argv[8];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,7 +119,7 @@ int main (int argc, char *argv[])
|
||||
tile_height = 1000;
|
||||
comp_prec = 8;
|
||||
irreversible = 1;
|
||||
strcpy(output_file, "test.j2k" );
|
||||
output_file = "test.j2k";
|
||||
}
|
||||
if( num_comps > NUM_COMPS_MAX )
|
||||
{
|
||||
@ -129,7 +129,9 @@ int main (int argc, char *argv[])
|
||||
l_data_size = (OPJ_UINT32)tile_width * (OPJ_UINT32)tile_height * (OPJ_UINT32)num_comps * (OPJ_UINT32)(comp_prec/8);
|
||||
|
||||
l_data = (OPJ_BYTE*) malloc(l_data_size * sizeof(OPJ_BYTE));
|
||||
|
||||
if(l_data == NULL){
|
||||
return 1;
|
||||
}
|
||||
fprintf(stdout, "Encoding random values -> keep in mind that this is very hard to compress\n");
|
||||
for (i=0;i<l_data_size;++i) {
|
||||
l_data[i] = (OPJ_BYTE)i; /*rand();*/
|
||||
@ -226,7 +228,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* should we do j2k or jp2 ?*/
|
||||
len = (unsigned char)strlen( output_file );
|
||||
len = strlen( output_file );
|
||||
if( strcmp( output_file + len - 4, ".jp2" ) == 0 )
|
||||
{
|
||||
l_codec = opj_create_compress(OPJ_CODEC_JP2);
|
||||
@ -236,6 +238,7 @@ int main (int argc, char *argv[])
|
||||
l_codec = opj_create_compress(OPJ_CODEC_J2K);
|
||||
}
|
||||
if (!l_codec) {
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -246,6 +249,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
l_image = opj_image_tile_create(num_comps,l_params,OPJ_CLRSPC_SRGB);
|
||||
if (! l_image) {
|
||||
free(l_data);
|
||||
opj_destroy_codec(l_codec);
|
||||
return 1;
|
||||
}
|
||||
@ -260,6 +264,7 @@ int main (int argc, char *argv[])
|
||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to setup the codec!\n");
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -268,6 +273,7 @@ int main (int argc, char *argv[])
|
||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to create the stream from the output file %s !\n",output_file );
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -276,6 +282,7 @@ int main (int argc, char *argv[])
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -285,6 +292,7 @@ int main (int argc, char *argv[])
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -294,6 +302,7 @@ int main (int argc, char *argv[])
|
||||
opj_stream_destroy(l_stream);
|
||||
opj_destroy_codec(l_codec);
|
||||
opj_image_destroy(l_image);
|
||||
free(l_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# UNIT TESTS
|
||||
# UNIT TESTS
|
||||
|
||||
include_directories(
|
||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
|
||||
|
158
thirdparty/CMakeLists.txt
vendored
158
thirdparty/CMakeLists.txt
vendored
@ -2,117 +2,117 @@
|
||||
|
||||
#------------
|
||||
# Try to find lib Z
|
||||
IF(BUILD_THIRDPARTY)
|
||||
if(BUILD_THIRDPARTY)
|
||||
# Try to build it
|
||||
message(STATUS "We will build Z lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(libz)
|
||||
SET(Z_LIBNAME z PARENT_SCOPE)
|
||||
SET(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE)
|
||||
SET(ZLIB_FOUND 1)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
add_subdirectory(libz)
|
||||
set(Z_LIBNAME z PARENT_SCOPE)
|
||||
set(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE)
|
||||
set(ZLIB_FOUND 1)
|
||||
else(BUILD_THIRDPARTY)
|
||||
# Try to find lib Z
|
||||
FIND_PACKAGE(ZLIB)
|
||||
IF(ZLIB_FOUND)
|
||||
SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
|
||||
SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
find_package(ZLIB)
|
||||
if(ZLIB_FOUND)
|
||||
set(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
|
||||
set(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
message(STATUS "Your system seems to have a Z lib available, we will use it to generate PNG lib")
|
||||
# message(STATUS "DEBUG: ${ZLIB_INCLUDE_DIRS} vs ${ZLIB_INCLUDE_DIR}")
|
||||
ELSE (ZLIB_FOUND) # not found
|
||||
else(ZLIB_FOUND) # not found
|
||||
message(STATUS "Z lib not found, activate BUILD_THIRDPARTY if you want build it (necessary to build libPNG)")
|
||||
ENDIF(ZLIB_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(ZLIB_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
||||
|
||||
#------------
|
||||
# Try to find lib PNG (which depends on zlib)
|
||||
IF(BUILD_THIRDPARTY)
|
||||
if(BUILD_THIRDPARTY)
|
||||
# Try to build it
|
||||
message(STATUS "We will build PNG lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(libpng)
|
||||
SET(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
SET(PNG_LIBNAME png PARENT_SCOPE)
|
||||
SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng PARENT_SCOPE)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
IF (ZLIB_FOUND)
|
||||
FIND_PACKAGE(PNG)
|
||||
IF(PNG_FOUND)
|
||||
add_subdirectory(libpng)
|
||||
set(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
set(PNG_LIBNAME png PARENT_SCOPE)
|
||||
set(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng PARENT_SCOPE)
|
||||
else(BUILD_THIRDPARTY)
|
||||
if(ZLIB_FOUND)
|
||||
find_package(PNG)
|
||||
if(PNG_FOUND)
|
||||
message(STATUS "Your system seems to have a PNG lib available, we will use it")
|
||||
SET(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
|
||||
SET(PNG_INCLUDE_DIRNAME ${PNG_PNG_INCLUDE_DIR} PARENT_SCOPE)
|
||||
ELSE(PNG_FOUND) # not found
|
||||
SET(OPJ_HAVE_PNG_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBPNG 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
|
||||
set(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
|
||||
set(PNG_INCLUDE_DIRNAME ${PNG_PNG_INCLUDE_DIR} PARENT_SCOPE)
|
||||
else(PNG_FOUND) # not found
|
||||
set(OPJ_HAVE_PNG_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBPNG 0 PARENT_SCOPE)
|
||||
message(STATUS "PNG lib not found, activate BUILD_THIRDPARTY if you want build it")
|
||||
ENDIF(PNG_FOUND)
|
||||
ENDIF (ZLIB_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(PNG_FOUND)
|
||||
endif(ZLIB_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
||||
#------------
|
||||
# Try to find lib TIFF
|
||||
|
||||
IF(BUILD_THIRDPARTY)
|
||||
if(BUILD_THIRDPARTY)
|
||||
# Try to build it
|
||||
message(STATUS "We will build TIFF lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(libtiff)
|
||||
SET(TIFF_LIBNAME tiff PARENT_SCOPE)
|
||||
SET(TIFF_INCLUDE_DIRNAME
|
||||
add_subdirectory(libtiff)
|
||||
set(TIFF_LIBNAME tiff PARENT_SCOPE)
|
||||
set(TIFF_INCLUDE_DIRNAME
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff
|
||||
${OPENJPEG_BINARY_DIR}/thirdparty/libtiff
|
||||
PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
FIND_PACKAGE(TIFF)
|
||||
IF(TIFF_FOUND)
|
||||
set(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
else(BUILD_THIRDPARTY)
|
||||
find_package(TIFF)
|
||||
if(TIFF_FOUND)
|
||||
message(STATUS "Your system seems to have a TIFF lib available, we will use it")
|
||||
SET(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
|
||||
SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
|
||||
ELSE (TIFF_FOUND) # not found
|
||||
SET(OPJ_HAVE_TIFF_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBTIFF 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
|
||||
set(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
|
||||
set(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
|
||||
else(TIFF_FOUND) # not found
|
||||
set(OPJ_HAVE_TIFF_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBTIFF 0 PARENT_SCOPE)
|
||||
message(STATUS "TIFF lib not found, activate BUILD_THIRDPARTY if you want build it")
|
||||
ENDIF(TIFF_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(TIFF_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
||||
#------------
|
||||
# Try to find lib LCMS2 (or by default LCMS)
|
||||
SET(OPJ_HAVE_LCMS_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LCMS_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS 0 PARENT_SCOPE)
|
||||
|
||||
IF( BUILD_THIRDPARTY)
|
||||
if( BUILD_THIRDPARTY)
|
||||
# Try to build lcms2
|
||||
message(STATUS "We will build LCMS2 lib from thirdparty")
|
||||
ADD_SUBDIRECTORY(liblcms2)
|
||||
SET(LCMS_LIBNAME lcms2 PARENT_SCOPE)
|
||||
SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
|
||||
SET(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
ELSE (BUILD_THIRDPARTY)
|
||||
FIND_PACKAGE(LCMS2)
|
||||
IF(LCMS2_FOUND)
|
||||
add_subdirectory(liblcms2)
|
||||
set(LCMS_LIBNAME lcms2 PARENT_SCOPE)
|
||||
set(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
|
||||
set(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
else(BUILD_THIRDPARTY)
|
||||
find_package(LCMS2)
|
||||
if(LCMS2_FOUND)
|
||||
message(STATUS "Your system seems to have a LCMS2 lib available, we will use it")
|
||||
SET(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
SET(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
|
||||
SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
ELSE (LCMS2_FOUND) # not found lcms2
|
||||
set(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
|
||||
set(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
|
||||
set(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
else(LCMS2_FOUND) # not found lcms2
|
||||
# try to find LCMS
|
||||
FIND_PACKAGE(LCMS)
|
||||
IF(LCMS_FOUND)
|
||||
find_package(LCMS)
|
||||
if(LCMS_FOUND)
|
||||
message(STATUS "Your system seems to have a LCMS lib available, we will use it")
|
||||
SET(OPJ_HAVE_LCMS_H 1 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS 1 PARENT_SCOPE)
|
||||
SET(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
|
||||
SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
ELSE (LCMS_FOUND) # not found lcms
|
||||
SET(OPJ_HAVE_LCMS2_H 0 PARENT_SCOPE)
|
||||
SET(OPJ_HAVE_LIBLCMS2 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LCMS_H 1 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS 1 PARENT_SCOPE)
|
||||
set(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
|
||||
set(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
else(LCMS_FOUND) # not found lcms
|
||||
set(OPJ_HAVE_LCMS2_H 0 PARENT_SCOPE)
|
||||
set(OPJ_HAVE_LIBLCMS2 0 PARENT_SCOPE)
|
||||
message(STATUS "LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
|
||||
ENDIF (LCMS_FOUND)
|
||||
ENDIF(LCMS2_FOUND)
|
||||
ENDIF(BUILD_THIRDPARTY)
|
||||
endif(LCMS_FOUND)
|
||||
endif(LCMS2_FOUND)
|
||||
endif(BUILD_THIRDPARTY)
|
||||
|
20
thirdparty/liblcms2/CMakeLists.txt
vendored
20
thirdparty/liblcms2/CMakeLists.txt
vendored
@ -1,19 +1,19 @@
|
||||
PROJECT(liblcms2 C)
|
||||
project(liblcms2 C)
|
||||
#
|
||||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
#
|
||||
FILE(GLOB SRCS src/*.c)
|
||||
FILE(GLOB HDRS include/*.h)
|
||||
file(GLOB SRCS src/*.c)
|
||||
file(GLOB HDRS include/*.h)
|
||||
#
|
||||
SET(LIBTARGET "lcms2")
|
||||
set(LIBTARGET "lcms2")
|
||||
#
|
||||
ADD_LIBRARY(${LIBTARGET} STATIC ${SRCS} ${HDRS})
|
||||
add_library(${LIBTARGET} STATIC ${SRCS} ${HDRS})
|
||||
#
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET} PROPERTIES PREFIX "lib")
|
||||
ENDIF(MSVC)
|
||||
if(MSVC)
|
||||
set_target_properties(${LIBTARGET} PROPERTIES PREFIX "lib")
|
||||
endif(MSVC)
|
||||
#
|
||||
SET_TARGET_PROPERTIES(${LIBTARGET}
|
||||
set_target_properties(${LIBTARGET}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "${LIBTARGET}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/lib)
|
||||
|
2
thirdparty/liblcms2/COPYING
vendored
2
thirdparty/liblcms2/COPYING
vendored
@ -1,5 +1,5 @@
|
||||
Little CMS
|
||||
Copyright (c) 1998-2010 Marti Maria Saguer
|
||||
Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
118
thirdparty/liblcms2/include/lcms2.h
vendored
118
thirdparty/liblcms2/include/lcms2.h
vendored
@ -1,7 +1,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2014 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
@ -23,7 +23,7 @@
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Version 2.6
|
||||
// Version 2.8
|
||||
//
|
||||
|
||||
#ifndef _lcms2_H
|
||||
@ -75,7 +75,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Version/release
|
||||
#define LCMS_VERSION 2060
|
||||
#define LCMS_VERSION 2080
|
||||
|
||||
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
|
||||
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
|
||||
@ -173,46 +173,45 @@ typedef int cmsBool;
|
||||
# define CMS_IS_WINDOWS_ 1
|
||||
#endif
|
||||
|
||||
// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
|
||||
// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
|
||||
// Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
|
||||
// on Unix-like systems, and allow it to be set on the compiler command line using
|
||||
// -DCMS_USE_BIG_ENDIAN or something similar
|
||||
#ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
|
||||
|
||||
#if defined(__sgi__) || defined(__sgi) || defined(sparc)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined(__s390__) || defined(__s390x__)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
# ifdef TARGET_CPU_PPC
|
||||
# if TARGET_CPU_PPC
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
# if CMS_USE_BIG_ENDIAN == 0
|
||||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
|
||||
#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# if defined (__GNUC__) && defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN)
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
// // Don't use big endian for PowerPC little endian mode
|
||||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#else // CMS_USE_BIG_ENDIAN
|
||||
|
||||
// WORDS_BIGENDIAN takes precedence
|
||||
#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
#endif
|
||||
# ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# else // WORDS_BIGENDIAN
|
||||
// Fall back to platform/compiler specific tests
|
||||
# if defined(__sgi__) || defined(__sgi) || defined(sparc)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
|
||||
# if defined(__s390__) || defined(__s390x__)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
|
||||
# ifdef macintosh
|
||||
# ifdef __BIG_ENDIAN__
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
# ifdef __LITTLE_ENDIAN__
|
||||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
# endif
|
||||
# endif // WORDS_BIGENDIAN
|
||||
|
||||
# if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
|
||||
#endif // CMS_USE_BIG_ENDIAN
|
||||
|
||||
#ifdef macintosh
|
||||
# ifdef __BIG_ENDIAN__
|
||||
# define CMS_USE_BIG_ENDIAN 1
|
||||
# endif
|
||||
# ifdef __LITTLE_ENDIAN__
|
||||
# undef CMS_USE_BIG_ENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Calling convention -- this is hardly platform and compiler dependent
|
||||
#ifdef CMS_IS_WINDOWS_
|
||||
@ -221,7 +220,7 @@ typedef int cmsBool;
|
||||
# define CMSEXPORT __stdcall _export
|
||||
# define CMSAPI
|
||||
# else
|
||||
# define CMSEXPORT _stdcall
|
||||
# define CMSEXPORT __stdcall
|
||||
# ifdef CMS_DLL_BUILD
|
||||
# define CMSAPI __declspec(dllexport)
|
||||
# else
|
||||
@ -383,7 +382,8 @@ typedef enum {
|
||||
cmsSigViewingCondDescTag = 0x76756564, // 'vued'
|
||||
cmsSigViewingConditionsTag = 0x76696577, // 'view'
|
||||
cmsSigVcgtTag = 0x76636774, // 'vcgt'
|
||||
cmsSigMetaTag = 0x6D657461 // 'meta'
|
||||
cmsSigMetaTag = 0x6D657461, // 'meta'
|
||||
cmsSigArgyllArtsTag = 0x61727473 // 'arts'
|
||||
|
||||
} cmsTagSignature;
|
||||
|
||||
@ -516,7 +516,7 @@ typedef enum {
|
||||
cmsSigNamedColorElemType = 0x6E636C20, // 'ncl '
|
||||
cmsSigLabV2toV4 = 0x32203420, // '2 4 '
|
||||
cmsSigLabV4toV2 = 0x34203220, // '4 2 '
|
||||
|
||||
|
||||
// Identities
|
||||
cmsSigIdentityElemType = 0x69646E20, // 'idn '
|
||||
|
||||
@ -524,7 +524,8 @@ typedef enum {
|
||||
cmsSigLab2FloatPCS = 0x64326C20, // 'd2l '
|
||||
cmsSigFloatPCS2Lab = 0x6C326420, // 'l2d '
|
||||
cmsSigXYZ2FloatPCS = 0x64327820, // 'd2x '
|
||||
cmsSigFloatPCS2XYZ = 0x78326420 // 'x2d '
|
||||
cmsSigFloatPCS2XYZ = 0x78326420, // 'x2d '
|
||||
cmsSigClipNegativesElemType = 0x636c7020 // 'clp '
|
||||
|
||||
} cmsStageSignature;
|
||||
|
||||
@ -655,7 +656,7 @@ typedef void* cmsHTRANSFORM;
|
||||
// T: Pixeltype
|
||||
// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
|
||||
// P: Planar? 0=Chunky, 1=Planar
|
||||
// X: swap 16 bps endianess?
|
||||
// X: swap 16 bps endianness?
|
||||
// S: Do swap? ie, BGR, KYMC
|
||||
// E: Extra samples
|
||||
// C: Channels (Samples per pixel)
|
||||
@ -898,7 +899,7 @@ typedef void* cmsHTRANSFORM;
|
||||
#define TYPE_ARGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1))
|
||||
#define TYPE_BGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
|
||||
#define TYPE_BGRA_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
|
||||
#define TYPE_ABGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
|
||||
#define TYPE_ABGR_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
|
||||
|
||||
#define TYPE_CMYK_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
|
||||
|
||||
@ -1002,6 +1003,10 @@ typedef struct {
|
||||
|
||||
} cmsICCViewingConditions;
|
||||
|
||||
// Get LittleCMS version (for shared objects) -----------------------------------------------------------------------------
|
||||
|
||||
CMSAPI int CMSEXPORT cmsGetEncodedCMMversion(void);
|
||||
|
||||
// Support of non-standard functions --------------------------------------------------------------------------------------
|
||||
|
||||
CMSAPI int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2);
|
||||
@ -1011,7 +1016,7 @@ CMSAPI long int CMSEXPORT cmsfilelength(FILE* f);
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
@ -1380,7 +1385,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
|
||||
cmsUInt32Number n;
|
||||
cmsContext ContextID;
|
||||
cmsContext ContextID;
|
||||
cmsPSEQDESC* seq;
|
||||
|
||||
} cmsSEQ;
|
||||
@ -1480,7 +1485,7 @@ CMSAPI int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignat
|
||||
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace);
|
||||
|
||||
// Build a suitable formatter for the colorspace of this profile
|
||||
// Build a suitable formatter for the colorspace of this profile. nBytes=1 means 8 bits, nBytes=2 means 16 bits.
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
|
||||
|
||||
@ -1509,6 +1514,7 @@ CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream);
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode);
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromNULL(cmsContext ContextID);
|
||||
CMSAPI cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile);
|
||||
CMSAPI cmsBool CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io);
|
||||
|
||||
// MD5 message digest --------------------------------------------------------------------------------------------------
|
||||
@ -1643,6 +1649,12 @@ CMSAPI cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID
|
||||
#define cmsFLAGS_CLUT_POST_LINEARIZATION 0x0001 // create postlinearization tables if possible
|
||||
#define cmsFLAGS_CLUT_PRE_LINEARIZATION 0x0010 // create prelinearization tables if possible
|
||||
|
||||
// Specific to unbounded mode
|
||||
#define cmsFLAGS_NONEGATIVES 0x8000 // Prevent negative numbers in floating point transforms
|
||||
|
||||
// Copy alpha channels when transforming
|
||||
#define cmsFLAGS_COPY_ALPHA 0x04000000 // Alpha channels are copied on cmsDoTransform()
|
||||
|
||||
// Fine-tune control over number of gridpoints
|
||||
#define cmsFLAGS_GRIDPOINTS(n) (((n) & 0xFF) << 16)
|
||||
|
||||
@ -1720,12 +1732,22 @@ CMSAPI void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
|
||||
void * OutputBuffer,
|
||||
cmsUInt32Number Size);
|
||||
|
||||
CMSAPI void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,
|
||||
CMSAPI void CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform, // Deprecated
|
||||
const void * InputBuffer,
|
||||
void * OutputBuffer,
|
||||
cmsUInt32Number Size,
|
||||
cmsUInt32Number Stride);
|
||||
|
||||
CMSAPI void CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM Transform,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
cmsUInt32Number BytesPerLineIn,
|
||||
cmsUInt32Number BytesPerLineOut,
|
||||
cmsUInt32Number BytesPerPlaneIn,
|
||||
cmsUInt32Number BytesPerPlaneOut);
|
||||
|
||||
|
||||
CMSAPI void CMSEXPORT cmsSetAlarmCodes(const cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
|
||||
CMSAPI void CMSEXPORT cmsGetAlarmCodes(cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
|
||||
|
42
thirdparty/liblcms2/include/lcms2_plugin.h
vendored
42
thirdparty/liblcms2/include/lcms2_plugin.h
vendored
@ -1,7 +1,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
@ -128,7 +128,7 @@ struct _cms_io_handler {
|
||||
const void* Buffer);
|
||||
};
|
||||
|
||||
// Endianess adjust functions
|
||||
// Endianness adjust functions
|
||||
CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
|
||||
CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
|
||||
CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
|
||||
@ -342,8 +342,8 @@ struct _cmstransform_struct;
|
||||
|
||||
typedef cmsUInt8Number* (* cmsFormatter16)(register struct _cmstransform_struct* CMMcargo,
|
||||
register cmsUInt16Number Values[],
|
||||
register cmsUInt8Number* Buffer,
|
||||
register cmsUInt32Number Stride);
|
||||
register cmsUInt8Number* Buffer,
|
||||
register cmsUInt32Number Stride);
|
||||
|
||||
typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
|
||||
cmsFloat32Number Values[],
|
||||
@ -571,11 +571,28 @@ typedef struct {
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
// Full xform
|
||||
typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo,
|
||||
|
||||
typedef struct {
|
||||
cmsUInt32Number BytesPerLineIn;
|
||||
cmsUInt32Number BytesPerLineOut;
|
||||
cmsUInt32Number BytesPerPlaneIn;
|
||||
cmsUInt32Number BytesPerPlaneOut;
|
||||
|
||||
} cmsStride;
|
||||
|
||||
typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, // Legacy function, handles just ONE scanline.
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number Size,
|
||||
cmsUInt32Number Stride);
|
||||
cmsUInt32Number Stride); // Stride in bytes to the next plana in planar formats
|
||||
|
||||
|
||||
typedef void (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo,
|
||||
const void* InputBuffer,
|
||||
void* OutputBuffer,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride);
|
||||
|
||||
typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
|
||||
void** UserData,
|
||||
@ -585,6 +602,14 @@ typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
|
||||
cmsUInt32Number* OutputFormat,
|
||||
cmsUInt32Number* dwFlags);
|
||||
|
||||
typedef cmsBool (* _cmsTransform2Factory)(_cmsTransform2Fn* xform,
|
||||
void** UserData,
|
||||
_cmsFreeUserDataFn* FreePrivateDataFn,
|
||||
cmsPipeline** Lut,
|
||||
cmsUInt32Number* InputFormat,
|
||||
cmsUInt32Number* OutputFormat,
|
||||
cmsUInt32Number* dwFlags);
|
||||
|
||||
|
||||
// Retrieve user data as specified by the factory
|
||||
CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
|
||||
@ -599,7 +624,10 @@ typedef struct {
|
||||
cmsPluginBase base;
|
||||
|
||||
// Transform entry point
|
||||
_cmsTransformFactory Factory;
|
||||
union {
|
||||
_cmsTransformFactory legacy_xform;
|
||||
_cmsTransform2Factory xform;
|
||||
} factories;
|
||||
|
||||
} cmsPluginTransform;
|
||||
|
||||
|
518
thirdparty/liblcms2/src/cmsalpha.c
vendored
Normal file
518
thirdparty/liblcms2/src/cmsalpha.c
vendored
Normal file
@ -0,0 +1,518 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
// is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "lcms2_internal.h"
|
||||
|
||||
|
||||
// Alpha copy ------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Floor to byte, taking care of saturation
|
||||
cmsINLINE cmsUInt8Number _cmsQuickSaturateByte(cmsFloat64Number d)
|
||||
{
|
||||
d += 0.5;
|
||||
if (d <= 0) return 0;
|
||||
if (d >= 255.0) return 255;
|
||||
|
||||
return (cmsUInt8Number) _cmsQuickFloorWord(d);
|
||||
}
|
||||
|
||||
|
||||
// Return the size in bytes of a given formatter
|
||||
static
|
||||
int trueBytesSize(cmsUInt32Number Format)
|
||||
{
|
||||
int fmt_bytes = T_BYTES(Format);
|
||||
|
||||
// For double, the T_BYTES field returns zero
|
||||
if (fmt_bytes == 0)
|
||||
return sizeof(double);
|
||||
|
||||
// Otherwise, it is already correct for all formats
|
||||
return fmt_bytes;
|
||||
}
|
||||
|
||||
|
||||
// Several format converters
|
||||
|
||||
typedef void(*cmsFormatterAlphaFn)(void* dst, const void* src);
|
||||
|
||||
|
||||
// From 8
|
||||
|
||||
static
|
||||
void copy8(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, 1);
|
||||
}
|
||||
|
||||
static
|
||||
void from8to16(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt8Number n = *(cmsUInt8Number*)src;
|
||||
*(cmsUInt16Number*) dst = FROM_8_TO_16(n);
|
||||
}
|
||||
|
||||
static
|
||||
void from8toFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = (*(cmsUInt8Number*)src) / 255.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from8toDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (*(cmsUInt8Number*)src) / 255.0;
|
||||
}
|
||||
|
||||
static
|
||||
void from8toHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = (*(cmsUInt8Number*)src) / 255.0f;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
// From 16
|
||||
|
||||
static
|
||||
void from16to8(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt16Number n = *(cmsUInt16Number*)src;
|
||||
*(cmsUInt8Number*) dst = FROM_16_TO_8(n);
|
||||
}
|
||||
|
||||
static
|
||||
void copy16(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, 2);
|
||||
}
|
||||
|
||||
void from16toFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
}
|
||||
|
||||
void from16toDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from16toHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
// From Float
|
||||
|
||||
static
|
||||
void fromFLTto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void copy32(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, sizeof(cmsFloat32Number));
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTtoDBL(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsFloat64Number*)dst = (cmsFloat64Number)n;
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTtoHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
|
||||
// From HALF
|
||||
|
||||
static
|
||||
void fromHLFto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFtoFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFtoDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (cmsFloat64Number)_cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
}
|
||||
|
||||
// From double
|
||||
static
|
||||
void fromDBLto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0);
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLtoFLT(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
*(cmsFloat32Number*)dst = (cmsFloat32Number) n;
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLtoHLF(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = (cmsFloat32Number) *(cmsFloat64Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
}
|
||||
|
||||
static
|
||||
void copy64(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, sizeof(cmsFloat64Number));
|
||||
}
|
||||
|
||||
|
||||
// Returns the position (x or y) of the formatter in the table of functions
|
||||
static
|
||||
int FormatterPos(cmsUInt32Number frm)
|
||||
{
|
||||
int b = T_BYTES(frm);
|
||||
|
||||
if (b == 0 && T_FLOAT(frm))
|
||||
return 4; // DBL
|
||||
if (b == 2 && T_FLOAT(frm))
|
||||
return 2; // HLF
|
||||
if (b == 4 && T_FLOAT(frm))
|
||||
return 3; // FLT
|
||||
if (b == 2 && !T_FLOAT(frm))
|
||||
return 1; // 16
|
||||
if (b == 1 && !T_FLOAT(frm))
|
||||
return 0; // 8
|
||||
|
||||
return -1; // not recognized
|
||||
|
||||
}
|
||||
|
||||
// Obtains a alpha-to-alpha funmction formatter
|
||||
static
|
||||
cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
|
||||
{
|
||||
static cmsFormatterAlphaFn FormattersAlpha[5][5] = {
|
||||
|
||||
/* from 8 */ { copy8, from8to16, from8toHLF, from8toFLT, from8toDBL },
|
||||
/* from 16*/ { from16to8, copy16, from16toHLF, from16toFLT, from16toDBL },
|
||||
/* from HLF*/ { fromHLFto8, fromHLFto16, copy16, fromHLFtoFLT, fromHLFtoDBL },
|
||||
/* from FLT*/ { fromFLTto8, fromFLTto16, fromFLTtoHLF, copy32, fromFLTtoDBL },
|
||||
/* from DBL*/ { fromDBLto8, fromDBLto16, fromDBLtoHLF, fromDBLtoFLT, copy64 }};
|
||||
|
||||
int in_n = FormatterPos(in);
|
||||
int out_n = FormatterPos(out);
|
||||
|
||||
if (in_n < 0 || out_n < 0 || in_n > 4 || out_n > 4) {
|
||||
|
||||
cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized alpha channel width");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return FormattersAlpha[in_n][out_n];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This function computes the distance from each component to the next one in bytes.
|
||||
static
|
||||
void ComputeIncrementsForChunky(cmsUInt32Number Format,
|
||||
cmsUInt32Number ComponentStartingOrder[],
|
||||
cmsUInt32Number ComponentPointerIncrements[])
|
||||
{
|
||||
cmsUInt32Number channels[cmsMAXCHANNELS];
|
||||
int extra = T_EXTRA(Format);
|
||||
int nchannels = T_CHANNELS(Format);
|
||||
int total_chans = nchannels + extra;
|
||||
int i;
|
||||
int channelSize = trueBytesSize(Format);
|
||||
int pixelSize = channelSize * total_chans;
|
||||
|
||||
// Sanity check
|
||||
if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
|
||||
return;
|
||||
|
||||
memset(channels, 0, sizeof(channels));
|
||||
|
||||
// Separation is independent of starting point and only depends on channel size
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentPointerIncrements[i] = pixelSize;
|
||||
|
||||
// Handle do swap
|
||||
for (i = 0; i < total_chans; i++)
|
||||
{
|
||||
if (T_DOSWAP(Format)) {
|
||||
channels[i] = total_chans - i - 1;
|
||||
}
|
||||
else {
|
||||
channels[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012
|
||||
if (T_SWAPFIRST(Format) && total_chans > 1) {
|
||||
|
||||
cmsUInt32Number tmp = channels[0];
|
||||
for (i = 0; i < total_chans-1; i++)
|
||||
channels[i] = channels[i + 1];
|
||||
|
||||
channels[total_chans - 1] = tmp;
|
||||
}
|
||||
|
||||
// Handle size
|
||||
if (channelSize > 1)
|
||||
for (i = 0; i < total_chans; i++) {
|
||||
channels[i] *= channelSize;
|
||||
}
|
||||
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentStartingOrder[i] = channels[i + nchannels];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// On planar configurations, the distance is the stride added to any non-negative
|
||||
static
|
||||
void ComputeIncrementsForPlanar(cmsUInt32Number Format,
|
||||
cmsUInt32Number BytesPerPlane,
|
||||
cmsUInt32Number ComponentStartingOrder[],
|
||||
cmsUInt32Number ComponentPointerIncrements[])
|
||||
{
|
||||
cmsUInt32Number channels[cmsMAXCHANNELS];
|
||||
int extra = T_EXTRA(Format);
|
||||
int nchannels = T_CHANNELS(Format);
|
||||
int total_chans = nchannels + extra;
|
||||
int i;
|
||||
int channelSize = trueBytesSize(Format);
|
||||
|
||||
// Sanity check
|
||||
if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
|
||||
return;
|
||||
|
||||
memset(channels, 0, sizeof(channels));
|
||||
|
||||
// Separation is independent of starting point and only depends on channel size
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentPointerIncrements[i] = channelSize;
|
||||
|
||||
// Handle do swap
|
||||
for (i = 0; i < total_chans; i++)
|
||||
{
|
||||
if (T_DOSWAP(Format)) {
|
||||
channels[i] = total_chans - i - 1;
|
||||
}
|
||||
else {
|
||||
channels[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle swap first (ROL of positions), example CMYK -> KCMY | 0123 -> 3012
|
||||
if (T_SWAPFIRST(Format) && total_chans > 0) {
|
||||
|
||||
cmsUInt32Number tmp = channels[0];
|
||||
for (i = 0; i < total_chans - 1; i++)
|
||||
channels[i] = channels[i + 1];
|
||||
|
||||
channels[total_chans - 1] = tmp;
|
||||
}
|
||||
|
||||
// Handle size
|
||||
for (i = 0; i < total_chans; i++) {
|
||||
channels[i] *= BytesPerPlane;
|
||||
}
|
||||
|
||||
for (i = 0; i < extra; i++)
|
||||
ComponentStartingOrder[i] = channels[i + nchannels];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Dispatcher por chunky and planar RGB
|
||||
static
|
||||
void ComputeComponentIncrements(cmsUInt32Number Format,
|
||||
cmsUInt32Number BytesPerPlane,
|
||||
cmsUInt32Number ComponentStartingOrder[],
|
||||
cmsUInt32Number ComponentPointerIncrements[])
|
||||
{
|
||||
if (T_PLANAR(Format)) {
|
||||
|
||||
ComputeIncrementsForPlanar(Format, BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
|
||||
}
|
||||
else {
|
||||
ComputeIncrementsForChunky(Format, ComponentStartingOrder, ComponentPointerIncrements);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handles extra channels copying alpha if requested by the flags
|
||||
void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
||||
void* out,
|
||||
cmsUInt32Number PixelsPerLine,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
cmsUInt32Number i, j, k;
|
||||
cmsUInt32Number nExtra;
|
||||
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
|
||||
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
|
||||
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
|
||||
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
|
||||
|
||||
cmsFormatterAlphaFn copyValueFn;
|
||||
|
||||
// Make sure we need some copy
|
||||
if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
|
||||
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.
|
||||
nExtra = T_EXTRA(p->InputFormat);
|
||||
if (nExtra != T_EXTRA(p->OutputFormat))
|
||||
return;
|
||||
|
||||
// Anything to do?
|
||||
if (nExtra == 0)
|
||||
return;
|
||||
|
||||
// Compute the increments
|
||||
ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements);
|
||||
ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements);
|
||||
|
||||
// Check for conversions 8, 16, half, float, dbl
|
||||
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(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
|
||||
|
||||
// The loop itself
|
||||
for (i = 0; i < LineCount; i++) {
|
||||
|
||||
// Prepare pointers for the loop
|
||||
for (j = 0; j < nExtra; j++) {
|
||||
|
||||
SourcePtr[j] = (cmsUInt8Number*)in + SourceStartingOrder[j] + SourceStrideIncrements[j];
|
||||
DestPtr[j] = (cmsUInt8Number*)out + DestStartingOrder[j] + DestStrideIncrements[j];
|
||||
}
|
||||
|
||||
for (j = 0; j < PixelsPerLine; j++) {
|
||||
|
||||
for (k = 0; k < nExtra; k++) {
|
||||
|
||||
copyValueFn(DestPtr[k], SourcePtr[k]);
|
||||
|
||||
SourcePtr[k] += SourceIncrements[k];
|
||||
DestPtr[k] += DestIncrements[k];
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < nExtra; j++) {
|
||||
|
||||
SourceStrideIncrements[j] += Stride->BytesPerLineIn;
|
||||
DestStrideIncrements[j] += Stride->BytesPerLineOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
2
thirdparty/liblcms2/src/cmscam02.c
vendored
2
thirdparty/liblcms2/src/cmscam02.c
vendored
@ -1,7 +1,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
|
34
thirdparty/liblcms2/src/cmscgats.c
vendored
34
thirdparty/liblcms2/src/cmscgats.c
vendored
@ -1,7 +1,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
@ -48,7 +48,7 @@
|
||||
// Symbols
|
||||
typedef enum {
|
||||
|
||||
SNONE,
|
||||
SUNDEFINED,
|
||||
SINUM, // Integer
|
||||
SDNUM, // Real
|
||||
SIDENT, // Identifier
|
||||
@ -324,7 +324,7 @@ static const char* PredefinedSampleID[] = {
|
||||
"XYZ_X", // X component of tristimulus data
|
||||
"XYZ_Y", // Y component of tristimulus data
|
||||
"XYZ_Z", // Z component of tristimulus data
|
||||
"XYY_X" // x component of chromaticity data
|
||||
"XYY_X", // x component of chromaticity data
|
||||
"XYY_Y", // y component of chromaticity data
|
||||
"XYY_CAPY", // Y component of tristimulus data
|
||||
"LAB_L", // L* component of Lab data
|
||||
@ -521,7 +521,7 @@ SYMBOL BinSrchKey(const char *id)
|
||||
else l = x + 1;
|
||||
}
|
||||
|
||||
return SNONE;
|
||||
return SUNDEFINED;
|
||||
}
|
||||
|
||||
|
||||
@ -596,7 +596,7 @@ void ReadReal(cmsIT8* it8, int inum)
|
||||
}
|
||||
|
||||
// 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
|
||||
static
|
||||
cmsFloat64Number ParseFloatNumber(const char *Buffer)
|
||||
@ -706,7 +706,7 @@ void InSymbol(cmsIT8* it8)
|
||||
|
||||
|
||||
key = BinSrchKey(it8->id);
|
||||
if (key == SNONE) it8->sy = SIDENT;
|
||||
if (key == SUNDEFINED) it8->sy = SIDENT;
|
||||
else it8->sy = key;
|
||||
|
||||
}
|
||||
@ -801,11 +801,11 @@ void InSymbol(cmsIT8* it8)
|
||||
|
||||
if (it8 ->sy == SINUM) {
|
||||
|
||||
sprintf(it8->id, "%d", it8->inum);
|
||||
snprintf(it8->id, 127, "%d", it8->inum);
|
||||
}
|
||||
else {
|
||||
|
||||
sprintf(it8->id, it8 ->DoubleFormatter, it8->dnum);
|
||||
snprintf(it8->id, 127, it8 ->DoubleFormatter, it8->dnum);
|
||||
}
|
||||
|
||||
k = (int) strlen(it8 ->id);
|
||||
@ -1297,7 +1297,7 @@ cmsHANDLE CMSEXPORT cmsIT8Alloc(cmsContext ContextID)
|
||||
it8->ValidKeywords = NULL;
|
||||
it8->ValidSampleID = NULL;
|
||||
|
||||
it8 -> sy = SNONE;
|
||||
it8 -> sy = SUNDEFINED;
|
||||
it8 -> ch = ' ';
|
||||
it8 -> Source = NULL;
|
||||
it8 -> inum = 0;
|
||||
@ -1363,7 +1363,7 @@ cmsBool CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFlo
|
||||
cmsIT8* it8 = (cmsIT8*) hIT8;
|
||||
char Buffer[1024];
|
||||
|
||||
sprintf(Buffer, it8->DoubleFormatter, Val);
|
||||
snprintf(Buffer, 1023, it8->DoubleFormatter, Val);
|
||||
|
||||
return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_UNCOOKED) != NULL;
|
||||
}
|
||||
@ -1373,7 +1373,7 @@ cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUIn
|
||||
cmsIT8* it8 = (cmsIT8*) hIT8;
|
||||
char Buffer[1024];
|
||||
|
||||
sprintf(Buffer, "%u", Val);
|
||||
snprintf(Buffer, 1023, "%u", Val);
|
||||
|
||||
return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_HEXADECIMAL) != NULL;
|
||||
}
|
||||
@ -1817,7 +1817,7 @@ cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number*
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------- Higer level parsing
|
||||
// -------------------------------------------------------------- Higher level parsing
|
||||
|
||||
static
|
||||
cmsBool DataFormatSection(cmsIT8* it8)
|
||||
@ -2120,7 +2120,7 @@ cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet)
|
||||
|
||||
|
||||
|
||||
// Init usefull pointers
|
||||
// Init useful pointers
|
||||
|
||||
static
|
||||
void CookPointers(cmsIT8* it8)
|
||||
@ -2516,8 +2516,10 @@ int LocateSample(cmsIT8* it8, const char* cSample)
|
||||
for (i=0; i < t->nSamples; i++) {
|
||||
|
||||
fld = GetDataFormat(it8, i);
|
||||
if (cmsstrcasecmp(fld, cSample) == 0)
|
||||
return i;
|
||||
if (fld != NULL) {
|
||||
if (cmsstrcasecmp(fld, cSample) == 0)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -2575,7 +2577,7 @@ cmsBool CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col, cmsFl
|
||||
|
||||
_cmsAssert(hIT8 != NULL);
|
||||
|
||||
sprintf(Buff, it8->DoubleFormatter, Val);
|
||||
snprintf(Buff, 255, it8->DoubleFormatter, Val);
|
||||
|
||||
return SetData(it8, row, col, Buff);
|
||||
}
|
||||
|
33
thirdparty/liblcms2/src/cmscnvrt.c
vendored
33
thirdparty/liblcms2/src/cmscnvrt.c
vendored
@ -1,7 +1,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
@ -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 };
|
||||
|
||||
// Duplicates the zone of memory used by the plug-in in the new context
|
||||
@ -269,6 +269,9 @@ cmsBool ComputeAbsoluteIntent(cmsFloat64Number AdaptationState,
|
||||
{
|
||||
cmsMAT3 Scale, m1, m2, m3, m4;
|
||||
|
||||
// TODO: Follow Marc Mahy's recommendation to check if CHAD is same by using M1*M2 == M2*M1. If so, do nothing.
|
||||
// TODO: Add support for ArgyllArts tag
|
||||
|
||||
// Adaptation state
|
||||
if (AdaptationState == 1.0) {
|
||||
|
||||
@ -288,7 +291,7 @@ cmsBool ComputeAbsoluteIntent(cmsFloat64Number AdaptationState,
|
||||
|
||||
|
||||
if (AdaptationState == 0.0) {
|
||||
|
||||
|
||||
m1 = *ChromaticAdaptationMatrixOut;
|
||||
_cmsMAT3per(&m2, &m1, &Scale);
|
||||
// m2 holds CHAD from output white to D50 times abs. col. scaling
|
||||
@ -530,7 +533,7 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
||||
cmsHPROFILE hProfile;
|
||||
cmsMAT3 m;
|
||||
cmsVEC3 off;
|
||||
cmsColorSpaceSignature ColorSpaceIn, ColorSpaceOut, CurrentColorSpace;
|
||||
cmsColorSpaceSignature ColorSpaceIn, ColorSpaceOut = cmsSigLabData, CurrentColorSpace;
|
||||
cmsProfileClassSignature ClassSig;
|
||||
cmsUInt32Number i, Intent;
|
||||
|
||||
@ -632,6 +635,22 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
||||
CurrentColorSpace = ColorSpaceOut;
|
||||
}
|
||||
|
||||
// Check for non-negatives clip
|
||||
if (dwFlags & cmsFLAGS_NONEGATIVES) {
|
||||
|
||||
if (ColorSpaceOut == cmsSigGrayData ||
|
||||
ColorSpaceOut == cmsSigRgbData ||
|
||||
ColorSpaceOut == cmsSigCmykData) {
|
||||
|
||||
cmsStage* clip = _cmsStageClipNegatives(Result->ContextID, cmsChannelsOf(ColorSpaceOut));
|
||||
if (clip == NULL) goto Error;
|
||||
|
||||
if (!cmsPipelineInsertStage(Result, cmsAT_END, clip))
|
||||
goto Error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
||||
Error:
|
||||
@ -870,7 +889,7 @@ int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt
|
||||
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];
|
||||
|
||||
// Apply TAC if needed
|
||||
@ -938,7 +957,7 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
|
||||
memset(&bp, 0, sizeof(bp));
|
||||
|
||||
// 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);
|
||||
if (bp.LabK2cmyk == NULL) goto Cleanup;
|
||||
|
||||
@ -1045,7 +1064,7 @@ cmsPipeline* _cmsLinkProfiles(cmsContext ContextID,
|
||||
if (TheIntents[i] == INTENT_PERCEPTUAL || TheIntents[i] == INTENT_SATURATION) {
|
||||
|
||||
// Force BPC for V4 profiles in perceptual and saturation
|
||||
if (cmsGetProfileVersion(hProfiles[i]) >= 4.0)
|
||||
if (cmsGetEncodedICCversion(hProfiles[i]) >= 0x4000000)
|
||||
BPC[i] = TRUE;
|
||||
}
|
||||
}
|
||||
|
15
thirdparty/liblcms2/src/cmserr.c
vendored
15
thirdparty/liblcms2/src/cmserr.c
vendored
@ -1,7 +1,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2016 Marti Maria Saguer
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the "Software"),
|
||||
@ -25,6 +25,13 @@
|
||||
|
||||
#include "lcms2_internal.h"
|
||||
|
||||
|
||||
// This function is here to help applications to prevent mixing lcms versions on header and shared objects.
|
||||
int CMSEXPORT cmsGetEncodedCMMversion(void)
|
||||
{
|
||||
return LCMS_VERSION;
|
||||
}
|
||||
|
||||
// I am so tired about incompatibilities on those functions that here are some replacements
|
||||
// that hopefully would be fully portable.
|
||||
|
||||
@ -191,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)
|
||||
{
|
||||
if (Plugin == NULL) {
|
||||
@ -423,14 +430,14 @@ void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size
|
||||
|
||||
// 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
|
||||
// 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
|
||||
// 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.
|
||||
// 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.
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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
|
||||
static
|
||||
cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user