summaryrefslogtreecommitdiff
path: root/src/bin/jp2
AgeCommit message (Collapse)Author
2024-02-28Fix some typos (found by `codespell` and `typos`)Stefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2024-01-08CMake: drop support for cmake < 3.5Dominik Wójt
Compatibility for cmake version < 3.5 is now deprecated in cmake and specifing version below 3.5 in cmake_minimum_required produces a warning.[1] [1] https://cmake.org/cmake/help/latest/release/3.27.html#deprecated-and-removed-features
2023-09-24Require `stdint.h` & `inttypes.h`mayeut
With #1450 which goes with 480cc9d49775d018c19ce0e01f6be27858d63d39 "Remove support for non-C99 compilers (like VS2010) that don't support snprintf()", support for MSVC versions prior to vs2015 is dropped: https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 This means that all supported MSVC versions do have `stdint.h` & `inttypes.h` now. For non windows platforms, those headers were already mandatory. Make them mandatory for all builds.
2023-03-09CMake: error out on warnings for strict/missing prototypes.Sebastian Rasmussen
And fix strict-prototypes/missing-prototypes warnings.
2022-08-11Cleanup code related to quality layer allocation, and add a few safety checksEven Rouault
2022-08-07CMake: switch to GNUInstallDirs (#1424)Thomas Bracht Laumann Jespersen
* Add GNUInstallDirs for standard installation directories Distributions are given standard variables for already existing hooks. Multiarch libdirs is taken care of automagically. Raises minimum cmake version by a little. * Handle CMAKE_INSTALL_xxx being absolute paths for .pc file generation In some cases the CMAKE_INSTAL_{BIN,MAN,DOC,LIB,INCLUDE}DIR variables may turn out to be absolute paths in which case prepending ${prefix} in the pkg-config .pc files will result in incorrect values. For .pc file generation, figure out if these variables are absolute and omit the prefix in the configured file when so. See: https://github.com/OSGeo/PROJ/commit/ab25e4b7ed9544e668282dcd293cfaaa2e56dbdf
2022-05-08opj_compress.c: usage formatting fixEven Rouault
2022-02-10Add support for partial bitstream decoding (#1407) (fixes #715)Robert Gabriel Jakabosky
Add a -allow-partial option to opj_decompress utility and a opj_decoder_set_strict_mode() option to the API Co-authored-by: Chris Hafey <chafey@gmail.com>
2022-01-23opj_encoder_set_extra_options(): add a GUARD_BITS=value optionEven Rouault
and add a -GuardBits option to opj_compress. The recently-released SMPTE DCP Bv2.1 Application Profile (link below) says that the number of guard bits in the QCD marker shall be 1 for 2K content and 2 for 4K content. This change allows the number of guard bits to be configured, so that users of openjpeg have the control they need to meet the specification. https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9161348 This is an alternative implementation of https://github.com/uclouvain/openjpeg/pull/1388 that keeps ABI unchanged.
2022-01-16Fix unsigned vs OPJ_INT32 mismatches (#1398)Eric Harvey
2022-01-15Added check for integer overflow in get_num_images (#1397)Eharve14
As discussed in pull request 1396, added a check for integer overflow. Change list: Defined num_images as unsigned int Moved the if statement to check for an empty directory to the beginning of the read directory section Added a check to see if num images would roll back to zero when incrementing.
2022-01-13Avoid overflow in multiplications in utilities related to big number of ↵Eharve14
files in a directory (CVE-2021-29338) (#1396)
2022-01-12opj_compress/opj_uncompress: fix integer overflow in num_images (#1395)Brad Parham
Includes the fix for CVE-2021-29338 Credit to @kaniini based on #1346 Fixes #1338
2021-12-10Remove duplicate assignments in function tiftoimageStefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-12-05Fix some typos (found by codespell)Stefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-10-27opj_compress: add a -TargetBitDepth switch for TIFF output (#1384)msheby
Sometimes, given the same (16-bit TIF) input, one wants to generate a variety of J2C outputs (say, 16-, 12-, and 10-bit). This patch allows one to downsample input files, and so makes it easier to automate OpenJPEG in mass generation of J2Cs without having to pipe though an image processing program.
2021-10-21API: deprecate 'bpp' member in favor of 'prec'Even Rouault
in opj_image_comp and opj_image_comptparm structures. bpp was redundant with prec, and almost never set by the library, except by opj_image_create(). This change should hopefully not impact existing, working, users of the API, which should already have used prec to get things working. Fixes #1379
2021-09-26opj_dump.c: fix potential buffer overflowEven Rouault
2021-09-25opj_decompress / opj_dump: accept .jph and .jhc extensions for HTJ2K filesEven Rouault
2021-09-12Use standard integer types for compatibility with libtiff 4.3.0 (#1377)Jamaika1
2021-07-14Fix segfault in src/bin/jp2/opj_decompress.c due to uninitialized pointer ↵xiaoxiaoafeifei
(fixes #1368) (#1369)
2021-06-07Add support for enabling generation of TLM markers in encoderEven Rouault
Support was already there, but restricted to Cinema and IMF profiles, and 255 tiles * Add -TLM switch added to opj_compress * Make opj_encoder_set_extra_options() function accept a TLM=YES option.
2021-06-07Fix various compiler warningsEven Rouault
2021-05-06Import files tiff and yuv(raw) (#1316)Jamaika1
2020-11-30pngtoimage(): fix wrong computation of x1,y1 if -d option is used, that ↵Even Rouault
would result in a heap buffer overflow (fixes #1284)
2020-10-09Merge pull request #1253 from rouault/floating_point_irreversible_encodingEven Rouault
Single-threaded performance improvements in forward DWT for 5-3 and 9-7 (and other improvements)
2020-06-30opj_decompress: fix double-free on input directory with mix of valid and ↵Even Rouault
invalid images (CVE-2020-15389) Fixes #1261 Credits to @Ruia-ruia for reporting and analysis.
2020-05-20Add multithreading support in the T1 (entropy phase) encoderEven Rouault
- API wise, opj_codec_set_threads() can be used on the encoding side - opj_compress has a -threads switch similar to opj_uncompress
2020-04-21Add support for generation of PLT markers in encoderEven Rouault
* -PLT switch added to opj_compress * Add a opj_encoder_set_extra_options() function that accepts a PLT=YES option, and could be expanded later for other uses. ------- Testing with a Sentinel2 10m band, T36JTT_20160914T074612_B02.jp2, coming from S2A_MSIL1C_20160914T074612_N0204_R135_T36JTT_20160914T081456.SAFE Decompress it to TIFF: ``` opj_uncompress -i T36JTT_20160914T074612_B02.jp2 -o T36JTT_20160914T074612_B02.tif ``` Recompress it with similar parameters as original: ``` opj_compress -n 5 -c [256,256],[256,256],[256,256],[256,256],[256,256] -t 1024,1024 -PLT -i T36JTT_20160914T074612_B02.tif -o T36JTT_20160914T074612_B02_PLT.jp2 ``` Dump codestream detail with GDAL dump_jp2.py utility (https://github.com/OSGeo/gdal/blob/master/gdal/swig/python/samples/dump_jp2.py) ``` python dump_jp2.py T36JTT_20160914T074612_B02.jp2 > /tmp/dump_sentinel2_ori.txt python dump_jp2.py T36JTT_20160914T074612_B02_PLT.jp2 > /tmp/dump_sentinel2_openjpeg_plt.txt ``` The diff between both show very similar structure, and identical number of packets in PLT markers Now testing with Kakadu (KDU803_Demo_Apps_for_Linux-x86-64_200210) Full file decompression: ``` kdu_expand -i T36JTT_20160914T074612_B02_PLT.jp2 -o tmp.tif Consumed 121 tile-part(s) from a total of 121 tile(s). Consumed 80,318,806 codestream bytes (excluding any file format) = 5.329697 bits/pel. Processed using the multi-threaded environment, with 8 parallel threads of execution ``` Partial decompresson (presumably using PLT markers): ``` kdu_expand -i T36JTT_20160914T074612_B02.jp2 -o tmp.pgm -region "{0.5,0.5},{0.01,0.01}" kdu_expand -i T36JTT_20160914T074612_B02_PLT.jp2 -o tmp2.pgm -region "{0.5,0.5},{0.01,0.01}" diff tmp.pgm tmp2.pgm && echo "same !" ``` ------- Funded by ESA for S2-MPC project
2020-04-01opj_decompress: add sanity checks to avoid segfault in case of decoding errorEven Rouault
Prevent crashes like: opj_decompress -i 0722_5-1_2019.jp2 -o out.ppm -r 4 -t 0 where 0722_5-1_2019.jp2 is https://drive.google.com/file/d/1ZxOUZg2-FKjYwa257VFLMpTXRWxEoP0a/view?usp=sharing
2020-02-13opj_compress: improve help message regarding new IMF switchEven Rouault
2020-02-12Implement writing of IMF profilesEven Rouault
Add -IMF switch to opj_compress as well
2019-09-03Merge pull request #1164 from sebras/masterEven Rouault
openjp2/j2k: Report error if all wanted components are not decoded.
2019-04-15bmp_read_rle4_data(): avoid potential infinite loopYoung Xiao
2019-04-15convertbmp: detect invalid file dimensions earlyYoung Xiao
width/length dimensions read from bmp headers are not necessarily valid. For instance they may have been maliciously set to very large values with the intention to cause DoS (large memory allocation, stack overflow). In these cases we want to detect the invalid size as early as possible. This commit introduces a counter which verifies that the number of written bytes corresponds to the advertized width/length. See commit 8ee335227bbc for details. Signed-off-by: Young Xiao <YangX92@hotmail.com>
2019-02-21openjp2/j2k: Report error if all wanted components are not decoded.Sebastian Rasmussen
Previously the caller had to check whether each component data had been decoded. This means duplicating the checking in every user of openjpeg which is unnecessary. If the caller wantes to decode all or a set of, or a specific component then openjpeg ought to error out if it was unable to do so. Fixes #1158.
2018-12-14convertbmp: detect invalid file dimensions earlyHugo Lefeuvre
width/length dimensions read from bmp headers are not necessarily valid. For instance they may have been maliciously set to very large values with the intention to cause DoS (large memory allocation, stack overflow). In these cases we want to detect the invalid size as early as possible. This commit introduces a counter which verifies that the number of written bytes corresponds to the advertized width/length. Fixes #1059 (CVE-2018-6616).
2018-11-16Merge pull request #1160 from hlef/masterEven Rouault
jp3d/jpwl convert: fix write stack buffer overflow
2018-11-07jp2: convert: fix null pointer dereferenceHugo Lefeuvre
Tile components in a JP2 image might have null data pointer by defining a zero component size (for example using large horizontal or vertical sampling periods). This null data pointer leads to null image component data pointer, causing crash when dereferenced without != null check in imagetopnm. Add != null check. This commit addresses #1152 (CVE-2018-18088).
2018-10-31Fix some potential overflow issues (#1161)Stefan Weil
* Fix some potential overflow issues Put sizeof to the beginning of the multiplication to enforce that size_t instead of smaller integer types is used for the calculation. This fixes warnings from LGTM: Multiplication result may overflow 'unsigned int' before it is converted to 'unsigned long'. It also allows removing some type casts. Signed-off-by: Stefan Weil <sw@weilnetz.de> * Fix code indentation Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-10-31Fix several memory and resource leaksNikola Forró
Signed-off-by: Nikola Forró <nforro@redhat.com>
2018-09-22Merge pull request #1148 from hlef/masterEven Rouault
CVE-2018-5785: fix issues with zero bitmasks
2018-09-22Merge pull request #1128 from stweil/typosEven Rouault
Fix some typos in code comments and documentation
2018-09-22convertbmp: fix issues with zero bitmasksHugo Lefeuvre
In the case where a BMP file declares compression 3 (BI_BITFIELDS) with header size <= 56, all bitmask values keep their initialization value 0. This may lead to various undefined behavior later e.g. when doing 1 << (l_comp->prec - 1). This issue does not affect files with bit count 16 because of a check added in 16240e2 which sets default values to the color masks if they are all 0. This commit adds similar checks for the 32 bit case. Also, if a BMP file declares compression 3 with header size >= 56 and intentional 0 bitmasks, the same issue will be triggered in both the 16 and 32 bit count case. This commit adds checks to bmp_read_info_header() rejecting BMP files with "intentional" 0 bitmasks. These checks might be removed in the future when proper handling of zero bitmasks will be available in openjpeg2. fixes #1057 (CVE-2018-5785)
2018-09-05Fix some typos in code comments and documentationStefan Weil
All typos were found by Codespell. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-08-31Changes in pnmtoimage if image data are missingszukw000
2018-06-16opj_compress: try to make help message of -c switch clearer (fixes #1117)Even Rouault
2018-03-12opj_compress: fix help message regarding default precinct sizeEven Rouault
2017-12-15Fix resource leak (CID 179466)Stefan Weil
Coverity report: CID 179466 (#1 of 1): Resource leak (RESOURCE_LEAK) 93. leaked_storage: Variable name going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-11-14Changed cmake version test to allow for cmake 2.8.11.xAndrew Murray