Commit Graph

26 Commits

Author SHA1 Message Date
Robert Gabriel Jakabosky 883c31dbe0
Add support for partial bitstream decoding (#1407) (fixes #715)
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-02-10 14:27:17 +01: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 7e2b6bebff Add capability to decode only a subset of all components of an image.
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-19 17:06:19 +02:00
szukw000 57e36dbfeb First change on changes-for-afl-tests 2017-08-02 17:27:08 +02:00
szukw000 00f45684a8 Catch images broken by AFL 2017-07-31 13:58:08 +02:00
Even Rouault 13cde9fa37 src/lib/openjp2/*.h: use OPJ_ prefix for inclusion guards instead of reserved __ (#587) 2017-07-30 19:46:52 +02:00
Even Rouault 5e795d90a1 Spelling fixes (patch by ka7, #890, rebased on top of master) 2017-07-26 21:06:38 +02:00
Even Rouault 3c2972f924 Reformat: apply reformattin on .h files (#128) 2017-05-15 12:21:30 +02:00
Even Rouault d4b7f03cfa Add opj_codec_set_threads() in public API and propagate resulting thread 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-05-25 21:02:07 +02:00
Stefan Weil 99fc1ab306 Fix typos in comments and string
Most typos were found by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-09-29 05:55:43 +02:00
mayeut a56819eaab Add some missing static keywords
Update uclouvain/openjpeg#243
2015-07-23 07:48:42 +02:00
Antonin Descampe 6868ee373e added memory allocation checks (fixes issue 355) 2014-09-19 10:26:35 +00:00
Antonin Descampe d19a4ab676 [trunk] updated copyright and added copyright notice required by ISO, in each file; updated AUTHORS, NEWS 2014-04-03 15:30:57 +00:00
Mickael Savinaud d5efeb7df5 [trunk]update the copyright, the authors and thanks to respect the license 2012-11-15 15:22:29 +00:00
Mickael Savinaud ec0fe09138 [trunk] move opj_bool to OPJ_BOOL to follow the other type 2012-11-15 13:13:36 +00:00
Mathieu Malaterre e189679ebc [trunk] Merge back JPIP modification into v2
This commit imports changes from openjpip.c from r2122 into openjpeg.c
2012-10-29 10:12:03 +00:00
Mickael Savinaud 94a69c2b31 [trunk] rename opj_j2k_v2 to opj_j2k 2012-10-25 14:27:09 +00:00
Mickael Savinaud 2257166e61 [trunk] rename opj_jp2_v2 to opj_jp2 2012-10-25 14:16:19 +00:00
Mickael Savinaud 56cf5f4f67 [trunk] remove old opj_jp2 struct 2012-10-25 14:11:19 +00:00
Mathieu Malaterre f3d7d2f7b1 [trunk] Rework r2077
r2077 did expose too much of the detail implementation of OpenJPEG. Rework dependencies in between JPIP file level details and JPIP client/server arch.
Move JPIP file level functionalities back into OpenJP2 as was the case in openjpeg 1.5.x. Use new cio func.
2012-10-25 07:39:59 +00:00
Mickael Savinaud fca9803bee [trunk] update jp2./.h to v2 style: use new OPJ type, manage case where bpcc box is available even if ihdr indicate that it is not needed; resolve a LH TODO 2012-10-24 12:49:28 +00:00
Mathieu Malaterre dff377a741 [trunk] Fix compilation:
- using mingw32 compiler (missing exported symbols)
- using -fvisibility=hidden (gcc on UNIX)
2012-10-15 09:44:34 +00:00
Mathieu Malaterre 75b7104724 [trunk] remove left-over from ->jpip_on implementation. JPIP is now completely removed from openjp2 and openmj2. Document jpip_iptr_offset variable 2012-10-15 07:38:10 +00:00
Mathieu Malaterre 9832c911b3 [trunk] Update JPIP (FolderReorgProposal task)
This commit does three things:
- Use opj_malloc/calloc/free instead of the default C ones.
- Update JPIP API to start using cio _v2 API
- Create a new opj_jpip_compress which is the replacement for image_to_j2k -jpip

Update issue 177
2012-10-08 15:59:17 +00:00
Mathieu Malaterre eda4c26d24 [trunk] Fix spelling. writting -> writing 2012-10-05 09:20:05 +00:00
Mathieu Malaterre d518970039 [trunk] Start FolderReorgProposal task
Update issue 177
2012-09-28 08:11:41 +00:00