Commit Graph

273 Commits

Author SHA1 Message Date
Eharve14 2947bf2850 Fixed signed issues in print statements, correced addtional signed issues in opj_compress.c related to signed integer use 2022-01-16 11:39:41 -05:00
Eharve14 8bb3ea7e71 Stylefix 2022-01-15 22:21:20 -05:00
Eharve14 1dbc41a06c fixed iterator issue in for loop to set up dirptr 2022-01-15 22:12:54 -05:00
Eharve14 85b248b1a8 Resloved issue where imagino used to iterate through files retrived was signed, causing possible overflow 2022-01-15 22:10:43 -05:00
Eharve14 fc88a3048b same as last 2022-01-15 21:54:37 -05:00
Eharve14 54a80d7c54 Reviesed to keep int type for other variables 2022-01-15 21:54:21 -05:00
Eharve14 76d50ceeb9 Corrected type for num_images in main, was singed integer 2022-01-15 20:54:25 -05:00
Eharve14 43bf2bec84 Re-Revised to use break statement instead of return. 2022-01-15 09:14:13 -05:00
Eharve14 67536c7144 Style fix 2022-01-14 21:51:23 -05:00
Eharve14 7766d9c81d Added return statement to break iteration 2022-01-14 21:20:18 -05:00
Eharve14 e011787bb1 Added import of limits.h, revised overflow check, Redefined Return value for get_num_images 2022-01-14 15:23:36 -05:00
Eharve14 081bc3e096 Fixed style 2022-01-13 16:36:23 -05:00
Eharve14 96c6587801 Same as last 2022-01-13 16:29:42 -05:00
Eharve14 912a144c27 Fixed issues with get_num_images, moved the zero file check to prevent exicution of allocation and strcpy if there are no images. 2022-01-13 16:29:30 -05:00
Eharve14 cbc8b26fb9 Revert "Added overflow check to get_num_images, defined num_images as unsigned for conformity, relocated check for num images for exicution before allocation and image loading"
This reverts commit ab6c7c7203.
2022-01-13 16:22:29 -05:00
Eharve14 957a6cd70e Revert "Fixed style"
This reverts commit dbe64d6fe0.
2022-01-13 16:22:23 -05:00
Eharve14 dbe64d6fe0 Fixed style 2022-01-13 16:15:56 -05:00
Eharve14 ab6c7c7203 Added overflow check to get_num_images, defined num_images as unsigned for conformity, relocated check for num images for exicution before allocation and image loading 2022-01-13 15:20:48 -05:00
Even Rouault e27cfb39c9
Update src/bin/jp2/opj_dump.c 2022-01-13 19:28:23 +01:00
Even Rouault 323a089003
Update src/bin/jp2/opj_dump.c 2022-01-13 19:22:22 +01:00
Eharve14 7c422579a3 Why, why is this happening 2022-01-13 13:17:40 -05:00
Eharve14 305819492c I am bad and I feel bad, I should have just used the scrypt 2022-01-13 13:05:58 -05:00
Eharve14 a0b7102434 Style part two 2022-01-13 13:02:57 -05:00
Eharve14 98f4acef63 style updates 2022-01-13 12:58:28 -05:00
Eharve14 efa9c7e76b Revised to casts, deleted all other changes 2022-01-13 12:48:58 -05:00
Eharve14 968cf54a95 Revised to catch negitive values of num_images 2022-01-13 12:04:59 -05:00
Eharve14 d8fe12641e Revert "Revised to address int overflow in for loop only"
This reverts commit e74ee84320.
2022-01-13 11:35:20 -05:00
Eric Harvey e74ee84320 Revised to address int overflow in for loop only 2022-01-13 10:44:11 -05:00
Eric Harvey fc2d47a369 Fixed typo 2022-01-13 02:20:52 -05:00
Eric Harvey d564919d3a Added multiplication check for calloc calls, see comment on commit 79c7d7a 2022-01-13 00:55:34 -05:00
Eric Harvey 33c2d33c5d Added multiplication check to calloc calls in opj_compress, opj_decompress, opj_dump. See comment on commit 79c7d7a. 2022-01-13 00:53:55 -05:00
Brad Parham 79c7d7af59
opj_compress/opj_uncompress: fix integer overflow in num_images (#1395)
Includes the fix for CVE-2021-29338
Credit to @kaniini based on #1346
Fixes #1338
2022-01-12 13:46:10 +01:00
Stefan Weil af8339d33f Remove duplicate assignments in function tiftoimage
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-12-10 11:29:06 +01:00
Stefan Weil 667149ffa1 Fix some typos (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-12-05 13:14:33 +01:00
msheby 90481203a2
opj_compress: add a -TargetBitDepth switch for TIFF output (#1384)
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-27 14:10:50 +02:00
Even Rouault 0b5d62684f
API: deprecate 'bpp' member in favor of 'prec'
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-10-21 14:13:58 +02:00
Even Rouault 15594a3dbf
opj_dump.c: fix potential buffer overflow 2021-09-26 12:37:59 +02:00
Even Rouault f3d8c763ba
opj_decompress / opj_dump: accept .jph and .jhc extensions for HTJ2K files 2021-09-25 12:26:59 +02:00
Jamaika1 8fc4bf8ecb
Use standard integer types for compatibility with libtiff 4.3.0 (#1377) 2021-09-12 12:32:38 +02:00
xiaoxiaoafeifei 0afbdcf3e6
Fix segfault in src/bin/jp2/opj_decompress.c due to uninitialized pointer (fixes #1368) (#1369) 2021-07-14 03:35:13 +02:00
Even Rouault a36ae03860
Add support for enabling generation of TLM markers in encoder
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-07 15:49:08 +02:00
Even Rouault f0629cb1c4
Fix various compiler warnings 2021-06-07 13:28:26 +02:00
Jamaika1 8aaafe6995
Import files tiff and yuv(raw) (#1316) 2021-05-06 19:30:34 +02:00
Even Rouault b2072402b7
pngtoimage(): fix wrong computation of x1,y1 if -d option is used, that would result in a heap buffer overflow (fixes #1284) 2020-11-30 22:31:51 +01:00
Even Rouault 491299eb07
Merge pull request #1253 from rouault/floating_point_irreversible_encoding
Single-threaded performance improvements in forward DWT for 5-3 and 9-7 (and other improvements)
2020-10-09 13:25:27 +02:00
Even Rouault e8e258ab04
opj_decompress: fix double-free on input directory with mix of valid and invalid images (CVE-2020-15389)
Fixes #1261

Credits to @Ruia-ruia for reporting and analysis.
2020-06-30 21:31:19 +02:00
Even Rouault 97eb7e0bf1
Add multithreading support in the T1 (entropy phase) encoder
- API wise, opj_codec_set_threads() can be used on the encoding side
- opj_compress has a -threads switch similar to opj_uncompress
2020-05-20 20:30:21 +02:00
Even Rouault 4edb8c8337
Add support for generation of PLT markers in encoder
* -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-21 15:55:44 +02:00
Even Rouault 1c54024165
opj_decompress: add sanity checks to avoid segfault in case of decoding error
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-04-01 21:11:36 +02:00
Even Rouault 563ecfb55c
opj_compress: improve help message regarding new IMF switch 2020-02-13 09:59:36 +01:00