Commit 8dfdbc1e authored by Mathieu Malaterre's avatar Mathieu Malaterre

Import Upstream version 2.1.2

parent af728730
# 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/
......@@ -21,6 +21,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
......
# 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))
- 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)
......
......@@ -33,7 +33,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_BUILD 1)
set(OPENJPEG_VERSION_BUILD 2)
set(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
set(PACKAGE_VERSION
......@@ -53,6 +53,7 @@ set(PACKAGE_VERSION
# 2.0.1 | 6
# 2.1 | 7
# 2.1.1 | 7
# 2.1.2 | 7
# 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
......@@ -67,7 +68,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})
# --------------------------------------------------------------------------
......@@ -163,8 +164,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
)
......@@ -226,7 +227,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)
......@@ -249,6 +250,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
......@@ -322,8 +324,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
......
......@@ -2,6 +2,11 @@
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
......
# 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).
......
......@@ -4,34 +4,35 @@ Many people have contributed to OpenJPEG by reporting problems, suggesting vario
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
Mathieu Malaterre
Julien Malik
Arnaud Maye
Vincent Nicolas
Glenn Pearson
Even Rouault
Dzonatas Sol
Winfried Szukalski
Vincent Torri
Yannick Verschueren
Peter Wimmer
* 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
* Glenn Pearson
* Even Rouault
* Dzonatas Sol
* Winfried Szukalski
* Vincent Torri
* Yannick Verschueren
* Peter Wimmer
......@@ -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
......
......@@ -1328,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;
}
......@@ -1377,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];
......@@ -1398,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;
......@@ -1478,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)
......@@ -1524,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)
{
if(ph->width && ph->height && ph->maxval) ph->ok = 1;
}
else
ph->ok = 1;
if(format == 1 || format == 4)
{
if(ph->width && ph->height) ph->ok = 1;
ph->maxval = 255;
}
}
......
......@@ -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);
......
......@@ -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");
......@@ -1029,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;
......@@ -1040,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;
......
......@@ -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
......
......@@ -5,7 +5,7 @@ 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
......@@ -110,11 +110,13 @@ 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
......
......@@ -129,16 +129,16 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT
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,11 +407,20 @@ 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) {
/* FIXME event manager error callback */
return OPJ_FALSE;
}
i = l;
......@@ -543,7 +552,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 ) {
......@@ -569,11 +578,23 @@ 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 mr; /* max resolution */
if (numres == 1U) {
return OPJ_TRUE;
}
h.mem = (OPJ_INT32*)opj_aligned_malloc(opj_dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32));
mr = opj_dwt_max_resolution(tr, numres);
/* overflow check */
if (mr > (SIZE_MAX / sizeof(OPJ_INT32))) {
/* FIXME event manager error callback */
return OPJ_FALSE;
}
mr *= sizeof(OPJ_INT32);
h.mem = (OPJ_INT32*)opj_aligned_malloc(mr);
if (! h.mem){
/* FIXME event manager error callback */
return OPJ_FALSE;
......@@ -582,7 +603,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;
......@@ -617,8 +638,8 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres
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 +681,8 @@ static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restric
}
}