Commit Graph

46 Commits

Author SHA1 Message Date
Even Rouault 1de5fc6c51
opj_encoder_set_extra_options(): add a GUARD_BITS=value option
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-23 17:54:44 +01:00
Aous Naman 1e6c925eb5
Added support for high throughput (HTJ2K) decoding.
There are a few limitations:
- mixed mode (HT and regular code blocks) is not supported.
- ROI in HT blocks is not supported.
- Placeholder passes are not supported.
- MultiHT sets are not support, only a singleHT set.
- there are known issues with some compliance testing files related to
  the parsing of packet header.
2021-09-25 12:26:59 +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 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 64689d05df
struct opj_j2k: remove unused fields, and add some documentation 2020-04-18 18:25:44 +02:00
Antonin Descampe d45ccb048b Merge pull request #1022 from rouault/partial_component_decoding
Add capability to decode only a subset of all components of an image.
2017-09-26 18:30:20 -03:00
Even Rouault b8c4b450c4 Use a #define J2K_MAX_POCS 32 to avoid hard-coded constant (#349) 2017-09-20 00:55:22 +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
Stefan Weil 10e6ce2c2c Use const qualifier for j2k_prog_order_list
This allows more compiler optimizations.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-08-14 14:41:27 +02:00
Even Rouault ac375ac9f5 Partial revert BPC related check of #975 (#979)
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-09 11:34:08 +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 4748318136 j2k.c: remove hardcoded constants related to m_state, and useless FIXME 2017-07-30 17:26:03 +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 8d2e69e37d Fix assertion / memory leak in opj_j2k_merge_ppt() on corrupted images (#939)
Fixes issue on id:000020,sig:06,src:001958,op:flip4,pos:149 that has two
SOT markers for the same tile with the same tile part number, causing
opj_j2k_merge_ppt() to be called several times.
2017-07-26 19:49:38 +02:00
Even Rouault a38c4496b6 Remove unused m_DA_x0, m_DA_y0, m_DA_x1, m_DA_y1 members from opj_j2k_dec structure 2017-07-05 21:33:42 +02:00
Even Rouault 532243f1fd MQC/RAW decoder: use an artificial 0xFF 0xFF terminating marker.
This saves comparing the current pointer with the end of buffer pointer.
This results at least in tiny speed improvement for raw decoding, and
smaller code size for MQC as well.

This kills the remains of the raw.h/.c files that were only used for
decoding. Encoding using the mqc structure already.
2017-06-02 18:24:07 +02:00
Even Rouault 3c2972f924 Reformat: apply reformattin on .h files (#128) 2017-05-15 12:21:30 +02:00
Antonin Descampe f66e120452 Merge branch 'bit-fields-type' of https://github.com/smuehlst/openjpeg into smuehlst-bit-fields-type 2016-09-13 21:21:11 +02:00
Stephan Mühlstrasser 54874194a8 Unified bit-field declaration, removed tabs. 2016-07-27 10:09:54 +02:00
Stephan Mühlstrasser d2d35bf6c2 Create separate type for bit-fields.
The definition of bit-fields with type OPJ_UINT32 caused complilation errors
on IBM iSeries, because OPJ_UINT32 is defined as uint32_t, and
uint32_t is defined as unsigned long in <stdint.h>. The definition of
bit-fields with an integer type of  a specific size doesn't make sense
anyway.
2016-07-25 20:46:11 +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
ak-dxdy 4fc1073809 French comments replaced by English ones 2015-07-31 00:51:08 +02:00
mayeut c887df12a3 Refactor opj_read_ppm
Update uclouvain/openjpeg#470
Update uclouvain/openjpeg#288
2015-07-12 18:09:30 +02:00
mayeut d1b053afe2 Refactor opj_j2k_read_ppt
Update uclouvain/openjpeg#470
Update uclouvain/openjpeg#532
2015-07-12 15:55:58 +02:00
mayeut c7535d084e Merge branch 'master' into issue-254 2015-06-05 20:42:57 +02:00
Matthieu Darbois daed8cc919 [trunk] Add check for at most 1 COD marker per tile. 1 COD marker for MH (fixes issue 476) 2015-05-19 20:13:37 +00:00
mayeut 00a47c1e06 Implement TNsot correction for non conforming files 2015-05-16 11:15:29 +02:00
Antonin Descampe 6868ee373e added memory allocation checks (fixes issue 355) 2014-09-19 10:26:35 +00:00
Antonin Descampe 7199d9b5d3 [trunk] refactoring of rsiz, profiles, and extensions management 2014-04-17 09:31:37 +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 b65bf48369 [trunk] merge from branch 1.5 a correction about large code-block data (decoding part) and add tests about issue 5 and issue 62 2012-12-18 17:46:33 +00:00
Mickael Savinaud fcf9fa3651 [trunk] add opj_ prefix to some internal define and use the new opj type instead of int and float in some files 2012-11-16 08:29:43 +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
Mickael Savinaud 84c93c2fea [trunk] rename public symbols with OPJ_ prefix 2012-11-15 12:25:11 +00:00
Mickael Savinaud 9b6900b058 [trunk] [trunk] remove old opj_tcp and rename opj_tcp_v2 to opj_tcp 2012-10-25 15:15:02 +00:00
Mickael Savinaud 7f7ef068fc [trunk] [trunk] remove old opj_cp and rename opj_cp_v2 to opj_cp 2012-10-25 15:09:31 +00:00
Mickael Savinaud 06615a556d [trunk] rename opj_tcd_truct_v2 to opj_tcd_struct 2012-10-25 14:49:10 +00:00
Mickael Savinaud 94a69c2b31 [trunk] rename opj_j2k_v2 to opj_j2k 2012-10-25 14:27:09 +00:00
Mickael Savinaud 425ff2f81d [trunk] remove old opj_j2k struct 2012-10-25 14:22:29 +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 f6622c2fbb [trunk] fix a compilation error with windows and new public function opj_j2k_start_compress 2012-10-15 13:00:31 +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 d518970039 [trunk] Start FolderReorgProposal task
Update issue 177
2012-09-28 08:11:41 +00:00