1199 Commits

Author SHA1 Message Date
Benjamin Gilbert
d42966d007 pkgconfig: drop unused libraries from Libs.private
Generate pkg-config Libs.private from the actual dependencies linked into
our libraries, rather than hardcoding static lists, to avoid overlinking
of library users when pkg-config is invoked with --static.  libopenjpip
doesn't actually link with libcurl, libfcgi, or libpthread, and neither
of our libraries links with libm on Windows (which doesn't have libm).
2025-07-24 23:54:22 -07:00
Even Rouault
e7453e398b
Merge pull request #1576 from weanti/master
code documentation updates
2025-02-11 13:06:41 +01:00
Mirco Miranda
578c67b329
Fixed ICC profile copy failure on write (#1574) 2025-02-11 13:05:58 +01:00
iantal
cc6d0c8ded
code documentation updates 2025-02-11 12:38:52 +01:00
Sebastian Rasmussen
f809b80c67 opj_jp2_read_header: Check for error after parsing header.
Consider the case where the caller has not set the p_image
pointer to NULL before calling opj_read_header().

If opj_j2k_read_header_procedure() fails while obtaining the rest
of the marker segment when calling opj_stream_read_data() because
the data stream is too short, then opj_j2k_read_header() will
never have the chance to initialize p_image, leaving it
uninitialized.

opj_jp2_read_header() will check the p_image value whether
opj_j2k_read_header() suceeded or failed. This may be detected as
an error in valgrind or ASAN.

The fix is to check whether opj_j2k_read_header() suceeded before
using the output argument p_image.
2025-01-16 02:24:21 +01:00
Even Rouault
ebbd7a1ffb
opj_compress: fix memory leak in error code path (when cannot create output file)
Fixes #1567
2024-12-06 03:57:44 +01:00
Even Rouault
98592ee6d6
sycc422_to_rgb(): fix out-of-bounds read accesses when 2 * width_component_1_or_2 + 1 == with_component_0
Fixes #1563

Also adjusts sycc420_to_rgb() for potential similar issue (amending
commit 7bd884f8750892de4f50bf4642fcfbe7011c6bdf)
2024-11-25 23:12:19 +01:00
Even Rouault
a1a56ff939
Merge pull request #1565 from rouault/fix_1564
opj_j2k_add_tlmarker(): validate that current tile-part number if smaller that total number of tile-parts
2024-11-25 23:09:36 +01:00
Even Rouault
e492644fbd
opj_j2k_add_tlmarker(): validate that current tile-part number if smaller that total number of tile-parts
Fixes #1564
2024-11-25 22:16:23 +01:00
Even Rouault
d5573aa5b8
Merge pull request #1560 from rouault/tune_TPSOT_FIX
Do not turn on 'TPsot==TNsot detection fix' when TNsot==1, and
2024-11-25 22:04:33 +01:00
Even Rouault
2be5f148eb
Ammend previous commit to remove new OPJ_DPARAMETERS_DISABLE_TPSOT_FIX flag, and make it active when opj_decoder_set_strict_mode() is called with true 2024-11-13 18:24:17 +01:00
Even Rouault
c34e44120d
Amend fix of PR 1530 regarding m_sot_length check
The fix of 2c0823cb30a70319c704565b59f496e490a3c7f9 (#1530) broke
decoding of some JPEG2000 files where Isot==0, Psot==0, TPsot==0 and
TNsot==0 like the following ones from the GDAL autotest suite:
autotest/gdrivers/data/jpeg2000/stefan_full_rgba_alpha_1bit.jp2
autotest/gdrivers/data/jpeg2000/3_13bit_and_1bit.jp2
2024-11-13 17:37:22 +01:00
Even Rouault
497d58c1ee
Do not turn on 'TPsot==TNsot detection fix' when TNsot==1, and add a OPJ_DPARAMETERS_DISABLE_TPSOT_FIX flag to disable it
Adresses the use case of https://lists.osgeo.org/pipermail/gdal-dev/2024-November/059805.html
where Sentinel2 L1C JPEG2000 files are made of a single tile-part per
tile.
2024-11-13 17:29:42 +01:00
Even Rouault
40707fd50d
opj_j2k_setup_encoder(): set numgbits = 1 for Cinema2K
Fixes #1340
2024-11-13 16:26:02 +01:00
sunyuechi
f6ea97aa36 bench_dwt: Add assert for memory allocation failure
Fix memory allocation failure on K230
2024-09-19 12:01:55 +08:00
Tomasz
e0e0c8026a
Add AVX2 and AVX512 optimization for wavelet transform (#1552)
Encoder: performance gain ~0.1%​
Decoder: performance gain ~2.5%
2024-09-06 14:59:48 +02:00
mayeut
c58bc128b4
fix: when EPH markers are specified, they are required.
reference from Rec. ITU-T T.800 (06/2019):
- Table A.13 – Coding style parameter values for the Scod parameter
- Section A.8.1 Start of packet (SOP)
- Section A.8.2 End of packet header (EPH)
2024-08-17 15:59:56 +02:00
Even Rouault
ed3a818370
Use TLM markers to optimize opj_decode() (on a subset of tiles) 2024-07-01 13:03:32 +02:00
Even Rouault
954c6e3cb9
Use TLM markers to optimize opj_get_decoded_tile() 2024-07-01 11:36:37 +02:00
Even Rouault
f3b28c5ee4
Avoid heap-buffer-overflow read on corrupted image in non-strict mode
Fixes #1535
2024-06-24 21:15:49 +02:00
Even Rouault
dea92eea8b
opj_j2k_read_sod(): validate opj_stream_read_data() return to avoid potential later heap-buffer-overflow in in opj_t1_decode_cblk when disabling strict mode
Fixes #1533
2024-06-21 15:08:28 +02:00
Andrew Murray
2f5a299cba
Support setting enumcs for CMYK and EYCC color space (#1529) 2024-06-14 14:21:12 +02:00
Even Rouault
1bca4d2f77
Merge pull request #1528 from rouault/fix_ossfuzz_68763
opj_j2k_decode_tiles(): avoid use of uninitialized l_current_tile_no variable
2024-06-14 13:22:30 +02:00
headshog
2c0823cb30
Fix Integer Overflow at j2k.c:9614 (#1530) 2024-05-31 18:19:38 +02:00
Even Rouault
3b0c9b91f5
opj_j2k_decode_tiles(): avoid use of uninitialized l_current_tile_no variable
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68763
2024-05-06 19:24:30 +02:00
Andrew Murray
7d95202435 Do not allow header length to be zero in non-zero length packet 2024-04-20 12:35:24 +10:00
Brad Smith
995d8c96b5
Fix building on OpenBSD big endian hosts
There is a swap16() function which conflicts with such a macro
in the endian.h header.  uint16_t swap16(uint16_t val16);

Do as suggested and rename the function to opj_swap16().
2024-03-04 22:12:38 +01:00
Kai Pastor
c28f012dae
Refactor build of both types of linkage 2024-03-04 22:10:05 +01:00
Kai Pastor
4b8b3970c5
Fix export of OPJ_STATIC macro 2024-03-04 22:10:05 +01:00
Stefan Weil
3beb2e1cee
Fix line endings (CRLF -> LF)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2024-03-04 22:10:05 +01:00
Stefan Weil
ce51a217e1
Fix some typos (found by codespell and typos)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2024-03-04 22:10:05 +01:00
Even Rouault
f19c21309e
opj_config.h.cmake.in: add inclusion guard 2024-02-27 15:54:37 +01:00
Even Rouault
e521a5094b
openjpeg.h: make sure to include opj_config.h (fixes #1514)
It was previously included by openjpeg.h
2024-02-27 12:50:40 +01:00
Even Rouault
017f2becdd
opj_t2_read_packet_header(): avoid unsigned integer overflow (alternate fix to https://github.com/uclouvain/openjpeg/pull/1488) 2024-02-18 18:02:09 +01:00
Even Rouault
0f3ca8108a
Merge pull request #1510 from rouault/fix_1505
opj_dwt_decode_tile(): avoid potential UndefinedBehaviorSanitizer 'applying zero offset to null pointer' (fixes #1505)
2024-02-18 17:43:23 +01:00
Even Rouault
89bf51c782
Merge pull request #1509 from rouault/fix_sycc420_to_rgb
opj_decompress: fix off-by-one read heap-buffer-overflow in sycc420_to_rgb() when x0 and y0 are odd (CVE-2021-3575, fixes #1347)
2024-02-18 17:18:36 +01:00
Even Rouault
d903fbb4ab
opj_dwt_decode_tile(): avoid potential UndefinedBehaviorSanitizer 'applying zero offset to null pointer' (fixes #1505) 2024-02-18 17:17:00 +01:00
Even Rouault
7bd884f875
opj_decompress: fix off-by-one read heap-buffer-overflow in sycc420_to_rgb() when x0 and y0 are odd (CVE-2021-3575, fixes #1347) 2024-02-18 17:02:25 +01:00
Dominik Wójt
65d0326e5a CMake: drop support for cmake < 3.5
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
2024-01-08 18:13:14 +01:00
scaramallion
3a100a337e Fix compiler error on Windows 2024-01-05 11:21:15 +11:00
Peter Johnson
41c25e3827
ht_dec.c: Improve MSVC arm64 popcount performance (#1479)
Use NEON instructions for ARM64 (implementation based on microsoft/STL#2127).

Godbolt output here: https://godbolt.org/z/q7GPTqT14
2023-12-09 22:02:11 +01:00
Even Rouault
dfdedea48f
Merge pull request #1496 from rouault/fix_1480
opj_tcd_dc_level_shift_decode(): avoid increment nullptr (fixes #1480)
2023-12-08 17:23:24 +01:00
Even Rouault
49c4ef5612
Merge pull request #1490 from headshog/fix-j2k
Integer Overflow at j2k.c:3962
2023-12-08 16:47:34 +01:00
Even Rouault
00e0bdc14f
Merge pull request #1491 from headshog/fix-j2k-header
Integer Overflow at j2k.c:11114
2023-12-08 16:47:27 +01:00
Even Rouault
03afd06b45
Merge pull request #1492 from headshog/fix-ht-dec
fix ht_dec.c:1215
2023-12-08 16:47:20 +01:00
Even Rouault
90312af28d
opj_tcd_dc_level_shift_decode(): avoid increment nullptr (fixes #1480)
(likely harmless issue as we don't dereference it)
2023-12-08 16:05:52 +01:00
Even Rouault
2c8c5025ce
Merge pull request #1484 from mayeut/mandatory-inttypes-stdint
Require `stdint.h` & `inttypes.h`
2023-12-08 15:55:00 +01:00
headshog
478b20d923
opj_t1_ht_decode_cblk(): avoid memcpy() with 0-input size and nullptr destination. fix ht_dec.c:1215 (#1492) 2023-12-08 15:24:28 +01:00
headshog
67e6a79bcf
fix j2k.c:11114 2023-12-08 15:17:53 +01:00
headshog
a817136f7e
opj_j2k_merge_ppm(): avoid unsigned-integer-overflow at j2k.c:3962 (#1490) 2023-12-08 15:03:54 +01:00