summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/jp2.c
AgeCommit message (Collapse)Author
2023-03-26opj_jp2_read_header(): move setting icc_profile here instead in ↵Even Rouault
opj_jp2_decode()/get_tile() + add unit test (fixes #570)
2023-03-17opj_jp2_read_header(): move setting color_space here instead in ↵Even Rouault
opj_jp2_decode()/get_tile() (fixes #570)
2022-08-12Fix Heap-buffer-overflow READ in opj_jp2_apply_pclr (#1441)Aleks L
The issue was found while fuzzing opencv: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47342 The read overflow triggered by reading `src[j]` in ```cpp for (j = 0; j < max; ++j) { dst[j] = src[j]; } ``` The max is calculated as `new_comps[pcol].w * new_comps[pcol].h`, however the `src = old_comps[cmp].data;` which may have different `w` and `h` dimensions.
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-18Fix potential overflow related issues spotted by LGTM code analysis (#1402)Eric Harvey
2021-12-05Fix some typos (found by codespell)Stefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2020-06-10Testing for invalid values of width, height, numcomps (#1254)szukw000
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-18struct opj_j2k: remove unused fields, and add some documentationEven Rouault
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-09-22opj_jp2_apply_pclr(): remove useless assert that can trigger on some files ↵Even Rouault
(fixes #1125)
2018-09-05openjp2/jp2: Fix two format stringsStefan Weil
Compiler warnings: src/lib/openjp2/jp2.c:1008:35: warning: too many arguments for format [-Wformat-extra-args] src/lib/openjp2/j2k.c:1928:73: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘OPJ_OFF_T {aka long int}’ [-Wformat=] Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-09-26Merge pull request #1022 from rouault/partial_component_decodingAntonin Descampe
Add capability to decode only a subset of all components of an image.
2017-09-19Fix badly named variable in function prototype (raised by cppcheck)Even Rouault
2017-09-19Add capability to decode only a subset of all components of an image.Even Rouault
This adds a opj_set_decoded_components(opj_codec_t *p_codec, OPJ_UINT32 numcomps, const OPJ_UINT32* comps_indices) function, and equivalent "opj_decompress -c compno[,compno]*" option. When specified, neither the MCT transform nor JP2 channel transformations will be applied. Tests added for various combinations of whole image vs tiled-based decoding, full or reduced resolution, use of decode area or not.
2017-09-08Use opj_image_data_free() where appropriate (adapted from ↵Even Rouault
https://github.com/uclouvain/openjpeg/pull/1015/commits/dab9db0723a5bb9f3d745f9dd7a0b8b3b18b8054, #1014)
2017-09-06Fix invalid access out of bounds, and bad behaviour, when calling repeatdly ↵Even Rouault
opj_get_decoded_tile() on an image with a color palette
2017-08-17Avoid asserting on assert(i == pcol) in opj_jp2_apply_pclr() by adding new ↵Even Rouault
check in opj_jp2_check_color(). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3068. Credit to OSS Fuzz
2017-08-09Partial revert BPC related check of #975 (#979)Even Rouault
PR #975 introduced a check that rejects images that have different bit depth/sign per compoment in SIZ marker if the JP2 IHDR box has BPC != 255 This didn't work properly if decoding a .j2k file since the new bit added in opj_cp_t wasn't initialized to the right value. For clarity, tThis new bit has also been renamed to allow_different_bit_depth_sign But looking closer at the code, it seems we were already tolerant to inconsistencies. For example we parsed a JP2 BPCC box even if BPC != 255 (just a warning is emitted) So failing hard in opj_j2k_read_siz() wouldn't be very inconsistent, and that alone cannot protect against other issues, so just emit a warning if BPC != 255 and the SIZ marker contains different bit depth/sign per component. Note: we could also check that the content of JP2 BPCC box is consistant with the one of the SIZ marker.
2017-08-08Merge pull request #975 from szukw000/changes-for-afl-testsAntonin Descampe
Catch images broken by AFL
2017-08-07opj_jp2_apply_pclr() also needs to use opj_image_data_alloc/opj_image_data_freeEven Rouault
2017-08-02First change on changes-for-afl-testsszukw000
2017-07-31Catch images broken by AFLszukw000
2017-07-30Fix warnings in USE_JPIP compilation modeEven Rouault
2017-07-30Fix Doxygen warnings (patch derived from Winfried's doxygen-dif.txt.zip, #849)Even Rouault
2017-07-30Avoid p_stream->m_user_data_length >= (OPJ_UINT64)p_stream->m_byte_offset ↵Even Rouault
assertion in opj_stream_get_number_byte_left(). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2786. Credit to OSS Fuzz
2017-07-28Fix null pointer dereference in opj_jp2_apply_pclr(). Fixes ↵Even Rouault
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2558. Credit to OSS Fuzz
2017-07-27opj_jp2_check_color(): replace assertion regarding mtyp by runtime check ↵Even Rouault
(#672, #895) Fixes test case openjeg-crashes-2017-07-27/id:000000,sig:06,src:000001,op:flip1,pos:808.jp2 of #895
2017-07-26Spelling fixes (patch by ka7, #890, rebased on top of master)Even Rouault
2017-05-23CMake: add stronger warnings for openjp2 lib/bin by default, and error out ↵Even Rouault
on declaration-after-statement And remove occurences of unused arguments in src/lib/openjp2
2017-05-09Reformat whole codebase with astyle.options (#128)Even Rouault
2016-09-08Merge branch 'master' of https://github.com/uclouvain/openjpeg into ↵Even Rouault
tier1_optimizations_multithreading_2 Conflicts: src/lib/openjp2/t1.c
2016-09-06Fix leak & invalid behavior of opj_jp2_read_ihdr (#818)Matthieu Darbois
In case multiple ihdr box are present, only the first one shall be taken into account.
2016-05-25Add opj_codec_set_threads() in public API and propagate resulting thread ↵Even Rouault
pool to tcd level By default, only the main thread is used. If opj_codec_set_threads() 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.
2016-04-29cppcheck fix for openjp2 (#740)julienmalik
2015-11-07Fix undefined size jp2 box handlingmayeut
Update #653
2015-10-29Fix typo in commentsStefan Weil
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-10-06Added missing casts for return values of opj_malloc()/opj_calloc().Stephan Mühlstrasser
2015-09-29Fix typos in comments and stringStefan Weil
Most typos were found by codespell. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-08-21Fix formattingmayeut
2015-08-21Merge pull request #559 from szukw000/cmyk-cielab-esyccMatthieu Darbois
Add support for CIELab, EYCC and CMYK
2015-07-30Defines three new functionsszukw000
Declares three new functions Calls the three new functions Collects data for CIELab, sets the color_space for EYCC and CMYK
2015-07-30Remove printf/fprintf to stdout/stderr throughout openjp2 libmayeut
Update uclouvain/openjpeg#246
2015-07-23Add some missing static keywordsmayeut
Update uclouvain/openjpeg#243
2015-07-12Add checks for odd looking cmap & for cmap outside jp2h boxmayeut
Update uclouvain/openjpeg#235 Update uclouvain/openjpeg#447
2015-01-20[trunk] checks for JP2 signature and file type boxes more carefullyAntonin Descampe
Update issue 430
2014-12-22[trunk] fixed compression check for 1 bit unsigned component (fixes issue 457)Matthieu Darbois
2014-11-24[trunk] removed warnings when building jp2.c (Update issue 442)Matthieu Darbois
2014-11-20[trunk] added check for pclr box validity (fixes issue 429)Matthieu Darbois
2014-11-18[trunk] remove warning during build (fixes issue 435)Matthieu Darbois