openjpeg.git
12 months agoDon't limit bitrate here, as DoM takes care of it (DoM bug #1665). carl-2
Carl Hetherington [Sat, 15 Apr 2023 21:51:50 +0000 (23:51 +0200)]
Don't limit bitrate here, as DoM takes care of it (DoM bug #1665).

3 years agoAllow configuration of the number of guard bits when encoding.
Carl Hetherington [Thu, 28 Jan 2021 21:24:24 +0000 (22:24 +0100)]
Allow configuration of the number of guard bits when encoding.

3 years agoFix Windows builds with ccache. ccache
Carl Hetherington [Thu, 11 Jun 2020 08:38:17 +0000 (10:38 +0200)]
Fix Windows builds with ccache.

4 years agoAdd some more errno to debug 'failed to start J2K encoding'
Carl Hetherington [Tue, 15 Jan 2019 16:56:31 +0000 (16:56 +0000)]
Add some more errno to debug 'failed to start J2K encoding'

4 years agoFix deprecated cscript bits.
Carl Hetherington [Sat, 17 Feb 2018 22:54:48 +0000 (22:54 +0000)]
Fix deprecated cscript bits.

4 years agoRevert "Packet header writing: set empty packet header bit to 0 when appropriate...
Carl Hetherington [Mon, 1 Jan 2018 23:57:07 +0000 (23:57 +0000)]
Revert "Packet header writing: set empty packet header bit to 0 when appropriate (small optimization)"

This reverts commit 2609fb8077125b5b31f1bcc2f98c12ff1e6572d7.

I am testing this reversion to see if it fixes problems with DCP
playback on various systems (DCP-o-matic bug #1136).

4 years agoFix from Aaron to match v1's threshold value.
Carl Hetherington [Sat, 2 Sep 2017 18:18:23 +0000 (19:18 +0100)]
Fix from Aaron to match v1's threshold value.

4 years agouse tolerance to bail out early from rate control : much faster
Aaron Boxer [Fri, 1 Sep 2017 23:33:40 +0000 (19:33 -0400)]
use tolerance to bail out early from rate control : much faster

4 years agoAdd some error codes to debug failure in opj_j2k_start_compress.
Carl Hetherington [Fri, 1 Sep 2017 23:23:25 +0000 (19:23 -0400)]
Add some error codes to debug failure in opj_j2k_start_compress.

4 years agoCompile with -fPIC so we can build shared libdcp with static openjp2.
Carl Hetherington [Fri, 1 Sep 2017 23:22:41 +0000 (19:22 -0400)]
Compile with -fPIC so we can build shared libdcp with static openjp2.

4 years agoAdd cscript
Carl Hetherington [Fri, 1 Sep 2017 23:20:14 +0000 (19:20 -0400)]
Add cscript

6 years agoopj_tcd_rateallocate(): make sure to use all passes for a lossless layer (#1009)
Even Rouault [Fri, 1 Sep 2017 18:01:39 +0000 (20:01 +0200)]
opj_tcd_rateallocate(): make sure to use all passes for a lossless layer (#1009)

And save a useless loop, which should be a tiny faster.

6 years agoopj_j2k_setup_encoder(): emit warnings if tcp_rates are not decreasing or tcp_distora...
Even Rouault [Fri, 1 Sep 2017 17:49:01 +0000 (19:49 +0200)]
opj_j2k_setup_encoder(): emit warnings if tcp_rates are not decreasing or tcp_distoratio are not increasing (#1009)

6 years agoopj_j2k_setup_encoder(): avoid potential int overflow in computations related to...
Even Rouault [Fri, 1 Sep 2017 17:27:56 +0000 (19:27 +0200)]
opj_j2k_setup_encoder(): avoid potential int overflow in computations related to max_cs_size

6 years agoopj_compress help: revert 32572617765cb9d77302384653a48d793b8f657f and indicate 1...
Even Rouault [Fri, 1 Sep 2017 17:16:35 +0000 (19:16 +0200)]
opj_compress help: revert 32572617765cb9d77302384653a48d793b8f657f and indicate 1 again as being the value to get lossless for -r. In opj_j2k_setup_encoder(), make sure that ll rates[] <= 1.0 are set to 0. Document 0 as being lossless for -q / tcp_distoratio (#1009)

6 years agoopj_compress help: indicate 0 value, instead of 1, for -r parameter to get lossless...
Even Rouault [Fri, 1 Sep 2017 15:32:54 +0000 (17:32 +0200)]
opj_compress help: indicate 0 value, instead of 1, for -r parameter to get lossless encoding (#1009)

6 years agoFix undefined shift behaviour in opj_dwt_is_whole_tile_decoding(). Fixes https:/...
Even Rouault [Fri, 1 Sep 2017 08:26:18 +0000 (10:26 +0200)]
Fix undefined shift behaviour in opj_dwt_is_whole_tile_decoding(). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3255. Credit to OSS Fuzz

6 years agoUse IDWT whole tile decoding if the area of interest equals to the image bounds,...
Even Rouault [Tue, 29 Aug 2017 09:40:53 +0000 (11:40 +0200)]
Use IDWT whole tile decoding if the area of interest equals to the image bounds, taking into account the reduced resolution factor

6 years agoAdd test for fix of a55c024fc6b917a409b85aeafd7326421c4aea34
Even Rouault [Mon, 28 Aug 2017 16:07:44 +0000 (18:07 +0200)]
Add test for fix of a55c024fc6b917a409b85aeafd7326421c4aea34

6 years agoSubtile decoding: fix overflows in subband coordinate computation that cause later...
Even Rouault [Mon, 28 Aug 2017 15:18:33 +0000 (17:18 +0200)]
Subtile decoding: fix overflows in subband coordinate computation that cause later buffer overflow. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3115. Credit to OSS Fuzz. master only

6 years agoMake opj_set_decode_area() and opj_decode() take into account opj_set_decoded_resolut...
Even Rouault [Mon, 28 Aug 2017 12:57:49 +0000 (14:57 +0200)]
Make opj_set_decode_area() and opj_decode() take into account opj_set_decoded_resolution_factor() (#1006, affect API use)

* Better document usage of opj_set_decode_area(), ie expecting coordinates
  in full resolution/reference grid even if requesting at a lower resolution
  factor
* Make sure that image->comps[].factor is set by opj_set_decode_area() and
  opj_decode() from the value specified in opj_set_decoded_resolution_factor()
* opj_decompress: add 2 environmenet variables to test alternate ways of
  using the API, namely USE_OPJ_SET_DECODED_RESOLUTION_FACTOR=YES to use
  opj_set_decoded_resolution_factor() instead of parameters.cp_reduce, and
  SKIP_OPJ_SET_DECODE_AREA=YES to not call opj_set_decode_area() if -d is
  not specified.

6 years agoAnother cleanup in knownfailures-* files
Even Rouault [Thu, 24 Aug 2017 12:38:24 +0000 (14:38 +0200)]
Another cleanup in knownfailures-* files

6 years agoRemove test steps from specialized knownfailures- that are already in knownfailures...
Even Rouault [Thu, 24 Aug 2017 12:32:36 +0000 (14:32 +0200)]
Remove test steps from specialized knownfailures- that are already in knownfailures-all.txt

6 years agoissue104_jpxstream.jp2 decompresses just fine (and like Kakadu). Update md5refs.txt...
Even Rouault [Thu, 24 Aug 2017 12:31:13 +0000 (14:31 +0200)]
issue104_jpxstream.jp2 decompresses just fine (and like Kakadu). Update md5refs.txt and remove from knownfailures

6 years agoRemove broken.jpc test from known failures, by avoiding too long processing time
Even Rouault [Thu, 24 Aug 2017 12:09:34 +0000 (14:09 +0200)]
Remove broken.jpc test from known failures, by avoiding too long processing time

6 years agoimagetopgx(): improve performance in 8 bit case (relates to broken.jpc test case)
Even Rouault [Thu, 24 Aug 2017 12:09:31 +0000 (14:09 +0200)]
imagetopgx(): improve performance in 8 bit case (relates to broken.jpc test case)

6 years agoRemove -NR-DEC-p1_06.j2k-156-decode and NR-DEC-p1_06.j2k-164-decode from knownfailures
Even Rouault [Thu, 24 Aug 2017 11:23:25 +0000 (13:23 +0200)]
Remove -NR-DEC-p1_06.j2k-156-decode and NR-DEC-p1_06.j2k-164-decode from knownfailures

and make them explicit failures. The result images are empty at the requested resolution

6 years agoopj_dwt_decode_partial_97(): perf improvement: limit copy of coefficients at end...
Even Rouault [Wed, 23 Aug 2017 16:58:32 +0000 (18:58 +0200)]
opj_dwt_decode_partial_97(): perf improvement: limit copy of coefficients at end of horizontal pass to actual range of interest

6 years agotest_tile_encoder: fix checks on argc
Even Rouault [Mon, 21 Aug 2017 21:06:53 +0000 (23:06 +0200)]
test_tile_encoder: fix checks on argc

6 years agoj2k.c: fix comment, and remove FIXME
Even Rouault [Mon, 21 Aug 2017 17:02:04 +0000 (19:02 +0200)]
j2k.c: fix comment, and remove FIXME

6 years agoAdd comment
Even Rouault [Mon, 21 Aug 2017 15:19:13 +0000 (17:19 +0200)]
Add comment

6 years agoMerge pull request #1001 from rouault/subtile_decoding_stage2
Even Rouault [Mon, 21 Aug 2017 11:02:07 +0000 (13:02 +0200)]
Merge pull request #1001 from rouault/subtile_decoding_stage2

Subtile decoding: only apply IDWT on areas that participate to the window of interest

6 years agoAdd comments for filter_width values 1001/head
Even Rouault [Mon, 21 Aug 2017 10:25:38 +0000 (12:25 +0200)]
Add comments for filter_width values

6 years agoSubtile decoding: only do 9x7 IDWT computations on relevant areas of tile-component...
Even Rouault [Sun, 20 Aug 2017 20:02:41 +0000 (22:02 +0200)]
Subtile decoding: only do 9x7 IDWT computations on relevant areas of tile-component buffer.

6 years agopgxtoimage(): avoid excessive memory allocation attempt (#999)
Even Rouault [Sat, 19 Aug 2017 13:45:54 +0000 (15:45 +0200)]
pgxtoimage(): avoid excessive memory allocation attempt (#999)

6 years agoSubtile decoding: only do 5x3 IDWT computations on relevant areas of tile-component...
Even Rouault [Fri, 18 Aug 2017 13:08:51 +0000 (15:08 +0200)]
Subtile decoding: only do 5x3 IDWT computations on relevant areas of tile-component buffer.

This lowers 'bin/opj_decompress -i ../MAPA.jp2 -o out.tif -d 0,0,256,256'
down to 0.860s

6 years agopgxtoimage(): fix write stack buffer overflow (#997)
Even Rouault [Fri, 18 Aug 2017 11:39:20 +0000 (13:39 +0200)]
pgxtoimage(): fix write stack buffer overflow (#997)

6 years agotest_decode_area: fix to make it work with odd image dimensions 990/head
Even Rouault [Fri, 18 Aug 2017 10:30:11 +0000 (12:30 +0200)]
test_decode_area: fix to make it work with odd image dimensions

6 years agobmp_read_rle8_data(): avoid potential infinite loop (#996)
Even Rouault [Fri, 18 Aug 2017 08:16:38 +0000 (10:16 +0200)]
bmp_read_rle8_data(): avoid potential infinite loop (#996)

6 years agoopj_j2k_update_rates(): grow tile size buffer for some situations
Even Rouault [Thu, 17 Aug 2017 17:18:48 +0000 (19:18 +0200)]
opj_j2k_update_rates(): grow tile size buffer for some situations

6 years agoZero-initialize tile buffer regions of skipped code-blocks, so as to make Valgrind...
Even Rouault [Thu, 17 Aug 2017 14:07:19 +0000 (16:07 +0200)]
Zero-initialize tile buffer regions of skipped code-blocks, so as to make Valgrind happy

6 years agoSub-tile decoding: only decode precincts and codeblocks that intersect the window...
Even Rouault [Mon, 14 Aug 2017 11:23:57 +0000 (13:23 +0200)]
Sub-tile decoding: only decode precincts and codeblocks that intersect the window specified in opj_set_decode_area()

6 years agoFix -Wconversion warning
Even Rouault [Thu, 17 Aug 2017 17:05:29 +0000 (19:05 +0200)]
Fix -Wconversion warning

6 years agobench_dwt.c: fix signedness related warnings
Even Rouault [Thu, 17 Aug 2017 15:04:48 +0000 (17:04 +0200)]
bench_dwt.c: fix signedness related warnings

6 years agoconvert.c: fix recently introduced -Wsign-conversion warnings
Even Rouault [Thu, 17 Aug 2017 15:02:40 +0000 (17:02 +0200)]
convert.c: fix recently introduced -Wsign-conversion warnings

6 years agoopj_getopt_long(): avoid infinite loop on invalid or missing value for an option...
Even Rouault [Thu, 17 Aug 2017 12:52:10 +0000 (14:52 +0200)]
opj_getopt_long(): avoid infinite loop on invalid or missing value for an option (#736)

6 years agoopj_decompress_fuzzer.cpp: reject images with too big tiles. Fixes https://bugs.chrom...
Even Rouault [Thu, 17 Aug 2017 10:01:16 +0000 (12:01 +0200)]
opj_decompress_fuzzer.cpp: reject images with too big tiles. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2918. Credit to OSS Fuzz

6 years agotgatoimage(): avoid excessive memory allocation attempt, and fixes unaligned load...
Even Rouault [Thu, 17 Aug 2017 09:47:40 +0000 (11:47 +0200)]
tgatoimage(): avoid excessive memory allocation attempt, and fixes unaligned load (#995)

6 years agoAvoid asserting on assert(i == pcol) in opj_jp2_apply_pclr() by adding new check...
Even Rouault [Thu, 17 Aug 2017 09:05:53 +0000 (11:05 +0200)]
Avoid asserting on assert(i == pcol) in opj_jp2_apply_pclr() by adding new check in opj_jp2_check_color(). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3068. Credit to OSS Fuzz

6 years agoopj_t1_encode_cblk(): avoid uint32 overflow when numbps = 0 (which is well defined...
Even Rouault [Wed, 16 Aug 2017 16:29:59 +0000 (18:29 +0200)]
opj_t1_encode_cblk(): avoid uint32 overflow when numbps = 0 (which is well defined behaviour, and is properly handled here, but better avoid it to detect real issues)

6 years agoFix build issue of JPWL by adding opj_image_data_alloc() and opj_image_data_free...
Even Rouault [Wed, 16 Aug 2017 15:38:47 +0000 (17:38 +0200)]
Fix build issue of JPWL by adding opj_image_data_alloc() and opj_image_data_free() to src/lib/openmj2 (#994)

6 years agoopj_t2_encode_packet(): fix potential write heap buffer overflow (#992)
Even Rouault [Wed, 16 Aug 2017 15:20:29 +0000 (17:20 +0200)]
opj_t2_encode_packet(): fix potential write heap buffer overflow (#992)

6 years agoopj_j2k_write_sot(): fix potential write heap buffer overflow (#991)
Even Rouault [Wed, 16 Aug 2017 15:09:10 +0000 (17:09 +0200)]
opj_j2k_write_sot(): fix potential write heap buffer overflow (#991)

6 years agotiftoimage(): fix read heap buffer overflow (#988)
Even Rouault [Wed, 16 Aug 2017 11:36:52 +0000 (13:36 +0200)]
tiftoimage(): fix read heap buffer overflow (#988)

The number of components is given only by TIFFTAG_SAMPLESPERPIXEL / tiSpp.
Querying TIFFTAG_EXTRASAMPLES only give information about which channel is
the alpha channel, but we mostly ignore it for now, so remove that part of the
code.

6 years agoimagetotga(): fix read heap buffer overflow if numcomps < 3 (#987)
Even Rouault [Wed, 16 Aug 2017 11:11:36 +0000 (13:11 +0200)]
imagetotga(): fix read heap buffer overflow if numcomps < 3 (#987)

6 years agoopj_t2_encode_packet(): only emit an error about insufficiently large output buffer...
Even Rouault [Wed, 16 Aug 2017 10:52:33 +0000 (12:52 +0200)]
opj_t2_encode_packet(): only emit an error about insufficiently large output buffer in FINAL_PASS mode. Fixes (master-only) regression added in 0b4fef6d1901254e41ab74ed681daba477d724c3

6 years agoFix assertion in debug mode / heap-based buffer overflow in opj_write_bytes_LE for...
Even Rouault [Tue, 15 Aug 2017 09:55:58 +0000 (11:55 +0200)]
Fix assertion in debug mode / heap-based buffer overflow in opj_write_bytes_LE for Cinema profiles with numresolutions = 1 (#985)

6 years agoMerge pull request #984 from stweil/const
Even Rouault [Mon, 14 Aug 2017 15:28:26 +0000 (17:28 +0200)]
Merge pull request #984 from stweil/const

Use more const qualifiers

6 years agobmp_read_info_header(): reject bmp files with biBitCount == 0 (#983)
Even Rouault [Mon, 14 Aug 2017 15:26:58 +0000 (17:26 +0200)]
bmp_read_info_header(): reject bmp files with biBitCount == 0 (#983)

6 years agoEncoder: grow buffer size in opj_tcd_code_block_enc_allocate_data() to avoid write...
Even Rouault [Mon, 14 Aug 2017 15:20:37 +0000 (17:20 +0200)]
Encoder: grow buffer size in opj_tcd_code_block_enc_allocate_data() to avoid write heap buffer overflow in opj_mqc_flush (#982)

6 years agoUse const qualifier for mqc_states 984/head
Stefan Weil [Mon, 14 Aug 2017 12:36:06 +0000 (14:36 +0200)]
Use const qualifier for mqc_states

This allows more compiler optimizations.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
6 years agoUse const qualifier for j2k_prog_order_list
Stefan Weil [Sun, 13 Aug 2017 20:57:31 +0000 (22:57 +0200)]
Use const qualifier for j2k_prog_order_list

This allows more compiler optimizations.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
6 years agoMerge pull request #980 from szukw000/changes-for-ppc64-converttif
Even Rouault [Fri, 11 Aug 2017 13:13:35 +0000 (15:13 +0200)]
Merge pull request #980 from szukw000/changes-for-ppc64-converttif

Changes in converttif.c for PPC64

6 years agoChanges in converttif.c for PPC64 980/head
szukw000 [Thu, 10 Aug 2017 22:06:23 +0000 (00:06 +0200)]
Changes in converttif.c for PPC64

6 years agoFix argument order in error message of previous commit
Even Rouault [Thu, 10 Aug 2017 14:58:36 +0000 (16:58 +0200)]
Fix argument order in error message of previous commit

6 years agoPropagate event manager down to opj_t2_encode_packet() and use it to emit an error...
Even Rouault [Thu, 10 Aug 2017 14:49:47 +0000 (16:49 +0200)]
Propagate event manager down to opj_t2_encode_packet() and use it to emit an error message when the output buffer is too small

6 years agoFix crash on encoding if using opj_set_default_encoder_parameters() without defining...
Even Rouault [Thu, 10 Aug 2017 12:43:16 +0000 (14:43 +0200)]
Fix crash on encoding if using opj_set_default_encoder_parameters() without defining tcp_numlayers

6 years agoReformat tests/test_tile_encoder.c
Even Rouault [Thu, 10 Aug 2017 10:30:31 +0000 (12:30 +0200)]
Reformat tests/test_tile_encoder.c

6 years agoImprove doc of opj_tccp_info_t::cblkw and cblkh
Even Rouault [Thu, 10 Aug 2017 09:45:49 +0000 (11:45 +0200)]
Improve doc of opj_tccp_info_t::cblkw and cblkh

6 years agoComment back previous version in abi-check.sh
Antonin Descampe [Thu, 10 Aug 2017 04:51:16 +0000 (21:51 -0700)]
Comment back previous version in abi-check.sh

6 years agoupdate abi-check for latest release
Antonin Descampe [Thu, 10 Aug 2017 04:35:30 +0000 (21:35 -0700)]
update abi-check for latest release

6 years agoPreparing Release v2.2.0 v2.2.0
Antonin Descampe [Thu, 10 Aug 2017 00:31:50 +0000 (17:31 -0700)]
Preparing Release v2.2.0

6 years agoPreparing Release v2.2.0
Antonin Descampe [Thu, 10 Aug 2017 00:28:17 +0000 (17:28 -0700)]
Preparing Release v2.2.0

6 years ago.travis.yml: add 'dist: precise' for config that requires it
Even Rouault [Wed, 9 Aug 2017 23:14:35 +0000 (01:14 +0200)]
.travis.yml: add 'dist: precise' for config that requires it

6 years agoRemove useless opj_tcd_t::enumcs field added per #975
Even Rouault [Wed, 9 Aug 2017 15:37:05 +0000 (17:37 +0200)]
Remove useless opj_tcd_t::enumcs field added per #975

6 years agoDoc: fix error in previous commit
Even Rouault [Wed, 9 Aug 2017 13:04:29 +0000 (15:04 +0200)]
Doc: fix error in previous commit

6 years agotcd.h: doc fixes and improvements
Even Rouault [Wed, 9 Aug 2017 12:50:59 +0000 (14:50 +0200)]
tcd.h: doc fixes and improvements

6 years agoDocument qmfbid values
Even Rouault [Wed, 9 Aug 2017 12:13:58 +0000 (14:13 +0200)]
Document qmfbid values

6 years agoPartial revert BPC related check of #975 (#979)
Even Rouault [Wed, 9 Aug 2017 09:34:08 +0000 (11:34 +0200)]
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.

6 years agoopj_decompress: document -quiet option, and remove spurious newline output
Even Rouault [Wed, 9 Aug 2017 08:03:59 +0000 (10:03 +0200)]
opj_decompress: document -quiet option, and remove spurious newline output

6 years agosrc/bin/jpwl/convert.c pgxtoimage(): add missing fclose() (#977)
Even Rouault [Wed, 9 Aug 2017 07:50:39 +0000 (09:50 +0200)]
src/bin/jpwl/convert.c pgxtoimage(): add missing fclose() (#977)

6 years agoimagetobmp: avoid shift by -1 (relates to #811)
Even Rouault [Wed, 9 Aug 2017 07:42:30 +0000 (09:42 +0200)]
imagetobmp: avoid shift by -1 (relates to #811)

6 years agoFix remaining warning
Antonin Descampe [Wed, 9 Aug 2017 01:05:37 +0000 (18:05 -0700)]
Fix remaining warning

format specifier mismatch in #975

6 years agoMerge pull request #975 from szukw000/changes-for-afl-tests
Antonin Descampe [Tue, 8 Aug 2017 23:51:54 +0000 (16:51 -0700)]
Merge pull request #975 from szukw000/changes-for-afl-tests

Catch images broken by AFL

6 years agoMerge pull request #968 from rouault/reduce_memory_decoding
Even Rouault [Mon, 7 Aug 2017 18:17:36 +0000 (20:17 +0200)]
Merge pull request #968 from rouault/reduce_memory_decoding

Reduce memory decoding

6 years agoSlight improvement in management of code block chunks 968/head
Even Rouault [Thu, 6 Jul 2017 17:34:21 +0000 (19:34 +0200)]
Slight improvement in management of code block chunks

Instead of having the chunk array at the segment level, we can move it down to
the codeblock itself since segments are filled in sequential order.
Limit the number of memory allocation, and decrease slightly the memory usage.

On MAPA_005.jp2

n4: 1871312549 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
 n1: 1610689344 0x4E781E7: opj_aligned_malloc (opj_malloc.c:61)
  n1: 1610689344 0x4E71D1B: opj_alloc_tile_component_data (tcd.c:676)
   n1: 1610689344 0x4E726CF: opj_tcd_init_decode_tile (tcd.c:816)
    n1: 1610689344 0x4E4BE39: opj_j2k_read_tile_header (j2k.c:8617)
     n1: 1610689344 0x4E4C902: opj_j2k_decode_tiles (j2k.c:10348)
      n1: 1610689344 0x4E4E3CE: opj_j2k_decode (j2k.c:7846)
       n1: 1610689344 0x4E53002: opj_jp2_decode (jp2.c:1564)
        n0: 1610689344 0x40374E: main (opj_decompress.c:1459)
 n1: 219232541 0x4E4BC50: opj_j2k_read_tile_header (j2k.c:4683)
  n1: 219232541 0x4E4C902: opj_j2k_decode_tiles (j2k.c:10348)
   n1: 219232541 0x4E4E3CE: opj_j2k_decode (j2k.c:7846)
    n1: 219232541 0x4E53002: opj_jp2_decode (jp2.c:1564)
     n0: 219232541 0x40374E: main (opj_decompress.c:1459)
 n1: 23893200 0x4E72735: opj_tcd_init_decode_tile (tcd.c:1225)
  n1: 23893200 0x4E4BE39: opj_j2k_read_tile_header (j2k.c:8617)
   n1: 23893200 0x4E4C902: opj_j2k_decode_tiles (j2k.c:10348)
    n1: 23893200 0x4E4E3CE: opj_j2k_decode (j2k.c:7846)
     n1: 23893200 0x4E53002: opj_jp2_decode (jp2.c:1564)
      n0: 23893200 0x40374E: main (opj_decompress.c:1459)
 n0: 17497464 in 52 places, all below massif's threshold (1.00%)

6 years agoDecoding: do not allocate memory for the codestream of each codeblock
Even Rouault [Thu, 6 Jul 2017 14:11:11 +0000 (16:11 +0200)]
Decoding: do not allocate memory for the codestream of each codeblock

Currently we allocate at least 8192 bytes for each codeblock, and copy
the relevant parts of the codestream in that per-codeblock buffer as we
decode packets.
As the whole codestream for the tile is ingested in memory and alive
during the decoding, we can directly point to it instead of copying. But
to do that, we need an intermediate concept, a 'chunk' of code-stream segment,
given that segments may be made of data at different places in the code-stream
when quality layers are used.

With that change, the decoding of MAPA_005.jp2 goes down from the previous
improvement of 2.7 GB down to 1.9 GB.

New profile:

n4: 1885648469 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
 n1: 1610689344 0x4E78287: opj_aligned_malloc (opj_malloc.c:61)
  n1: 1610689344 0x4E71D7B: opj_alloc_tile_component_data (tcd.c:676)
   n1: 1610689344 0x4E7272C: opj_tcd_init_decode_tile (tcd.c:816)
    n1: 1610689344 0x4E4BDD9: opj_j2k_read_tile_header (j2k.c:8618)
     n1: 1610689344 0x4E4C8A2: opj_j2k_decode_tiles (j2k.c:10349)
      n1: 1610689344 0x4E4E36E: opj_j2k_decode (j2k.c:7847)
       n1: 1610689344 0x4E52FA2: opj_jp2_decode (jp2.c:1564)
        n0: 1610689344 0x40374E: main (opj_decompress.c:1459)
 n1: 219232541 0x4E4BBF0: opj_j2k_read_tile_header (j2k.c:4685)
  n1: 219232541 0x4E4C8A2: opj_j2k_decode_tiles (j2k.c:10349)
   n1: 219232541 0x4E4E36E: opj_j2k_decode (j2k.c:7847)
    n1: 219232541 0x4E52FA2: opj_jp2_decode (jp2.c:1564)
     n0: 219232541 0x40374E: main (opj_decompress.c:1459)
 n1: 39822000 0x4E727A9: opj_tcd_init_decode_tile (tcd.c:1219)
  n1: 39822000 0x4E4BDD9: opj_j2k_read_tile_header (j2k.c:8618)
   n1: 39822000 0x4E4C8A2: opj_j2k_decode_tiles (j2k.c:10349)
    n1: 39822000 0x4E4E36E: opj_j2k_decode (j2k.c:7847)
     n1: 39822000 0x4E52FA2: opj_jp2_decode (jp2.c:1564)
      n0: 39822000 0x40374E: main (opj_decompress.c:1459)
 n0: 15904584 in 52 places, all below massif's threshold (1.00%)

6 years agoAdd documentation for magic values in the code
Even Rouault [Thu, 6 Jul 2017 11:23:29 +0000 (13:23 +0200)]
Add documentation for magic values in the code

6 years agoopj_jp2_apply_pclr() also needs to use opj_image_data_alloc/opj_image_data_free
Even Rouault [Thu, 6 Jul 2017 00:17:26 +0000 (02:17 +0200)]
opj_jp2_apply_pclr() also needs to use opj_image_data_alloc/opj_image_data_free

6 years agoComplementary fix to previous commit
Even Rouault [Thu, 6 Jul 2017 00:02:25 +0000 (02:02 +0200)]
Complementary fix to previous commit

6 years agoAdd opj_image_data_alloc() / opj_image_data_free()
Even Rouault [Wed, 5 Jul 2017 23:47:40 +0000 (01:47 +0200)]
Add opj_image_data_alloc() / opj_image_data_free()

As bin/common/color.c used to directly call malloc()/free(), we need
to export functions dedicated to allocating/freeing image component data.

6 years agoFix crash on Windows due to b7594c0fcb9dd3aa6356d72c4a525d76168da689
Even Rouault [Wed, 5 Jul 2017 23:05:24 +0000 (01:05 +0200)]
Fix crash on Windows due to b7594c0fcb9dd3aa6356d72c4a525d76168da689

b7594c0fcb9dd3aa6356d72c4a525d76168da689 may put opj_tcd_tilecomp_t->data
allocated by opj_alloc_tile_component_data() as the image->comps[].data. As
opj_alloc_tile_component_data() use opj_aligned_malloc() we must be sure to
ue opj_alined_malloc()/_free() in all places where we alloc/free
image->comps[].data.

Note: this might have some compatibility impact in case user code does itself
the allocation/free of image->comps[].data

6 years agoDecrease memory consumption for whole image single tile decoding.
Even Rouault [Wed, 5 Jul 2017 21:48:28 +0000 (23:48 +0200)]
Decrease memory consumption for whole image single tile decoding.

We can use the same buffer for the tile decoding and the final image, and
save the intermediate buffer to transfer between those.

Effect on the decoding of MAPA (9944 x 13498 x 3 components of size byte)

Peak memory from 4.5 GB to 2.7 GB

Now:
n5: 2699708767 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
 n1: 1610689344 0x4E77E07: opj_aligned_malloc (opj_malloc.c:61) <-- final image
  n1: 1610689344 0x4E7195B: opj_alloc_tile_component_data (tcd.c:676)
   n1: 1610689344 0x4E722D2: opj_tcd_init_decode_tile (tcd.c:816)
    n1: 1610689344 0x4E4BCF1: opj_j2k_read_tile_header (j2k.c:8597)
     n1: 1610689344 0x4E4C742: opj_j2k_decode_tiles (j2k.c:10324)
      n1: 1610689344 0x4E4E20E: opj_j2k_decode (j2k.c:7826)
       n1: 1610689344 0x4E52E42: opj_jp2_decode (jp2.c:1564)
        n0: 1610689344 0x40369E: main (opj_decompress.c:1459)
 n1: 815554560 0x4E72231: opj_tcd_init_decode_tile (tcd.c:1217) <-- working memory for code blocks: 9944*13498/64/64*8192*3
  n1: 815554560 0x4E4BCF1: opj_j2k_read_tile_header (j2k.c:8597)
   n1: 815554560 0x4E4C742: opj_j2k_decode_tiles (j2k.c:10324)
    n1: 815554560 0x4E4E20E: opj_j2k_decode (j2k.c:7826)
     n1: 815554560 0x4E52E42: opj_jp2_decode (jp2.c:1564)
      n0: 815554560 0x40369E: main (opj_decompress.c:1459)
 n1: 219758391 0x4E4C0BF: opj_j2k_read_tile_header (j2k.c:4661) <-- ingestion of code stream
  n1: 219758391 0x4E4C742: opj_j2k_decode_tiles (j2k.c:10324)
   n1: 219758391 0x4E4E20E: opj_j2k_decode (j2k.c:7826)
    n1: 219758391 0x4E52E42: opj_jp2_decode (jp2.c:1564)
     n0: 219758391 0x40369E: main (opj_decompress.c:1459)
 n1: 39822000 0x4E7224F: opj_tcd_init_decode_tile (tcd.c:1224) <-- OPJ_J2K_DEFAULT_NB_SEGS*sizeof(opj_tcd_seg_t) per codeblock
  n1: 39822000 0x4E4BCF1: opj_j2k_read_tile_header (j2k.c:8597)
   n1: 39822000 0x4E4C742: opj_j2k_decode_tiles (j2k.c:10324)
    n1: 39822000 0x4E4E20E: opj_j2k_decode (j2k.c:7826)
     n1: 39822000 0x4E52E42: opj_jp2_decode (jp2.c:1564)
      n0: 39822000 0x40369E: main (opj_decompress.c:1459)
 n0: 13884472 in 49 places, all below massif's threshold (1.00%)

Before:
n5: 4493329848 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
 n2: 1610709160 0x4E77C87: opj_aligned_malloc (opj_malloc.c:61)
  n1: 1610689344 0x4E717DB: opj_alloc_tile_component_data (tcd.c:676)
   n1: 1610689344 0x4E72152: opj_tcd_init_decode_tile (tcd.c:816)
    n1: 1610689344 0x4E4BCF1: opj_j2k_read_tile_header (j2k.c:8597)
     n1: 1610689344 0x4E4C64A: opj_j2k_decode_tiles (j2k.c:10318)
      n1: 1610689344 0x4E4E08E: opj_j2k_decode (j2k.c:7826)
       n1: 1610689344 0x4E52CC2: opj_jp2_decode (jp2.c:1564)
        n0: 1610689344 0x40369E: main (opj_decompress.c:1459)
  n0: 19816 in 2 places, all below massif's threshold (1.00%)
 n1: 1610689344 0x4E43F36: opj_j2k_update_image_data.isra.7 (j2k.c:8743)
  n1: 1610689344 0x4E4C5C1: opj_j2k_decode_tiles (j2k.c:10358)
   n1: 1610689344 0x4E4E08E: opj_j2k_decode (j2k.c:7826)
    n1: 1610689344 0x4E52CC2: opj_jp2_decode (jp2.c:1564)
     n0: 1610689344 0x40369E: main (opj_decompress.c:1459)
 n1: 815554560 0x4E720B1: opj_tcd_init_decode_tile (tcd.c:1217)
  n1: 815554560 0x4E4BCF1: opj_j2k_read_tile_header (j2k.c:8597)
   n1: 815554560 0x4E4C64A: opj_j2k_decode_tiles (j2k.c:10318)
    n1: 815554560 0x4E4E08E: opj_j2k_decode (j2k.c:7826)
     n1: 815554560 0x4E52CC2: opj_jp2_decode (jp2.c:1564)
      n0: 815554560 0x40369E: main (opj_decompress.c:1459)
 n1: 402672336 0x4E4C545: opj_j2k_decode_tiles (j2k.c:10336)
  n1: 402672336 0x4E4E08E: opj_j2k_decode (j2k.c:7826)
   n1: 402672336 0x4E52CC2: opj_jp2_decode (jp2.c:1564)
    n0: 402672336 0x40369E: main (opj_decompress.c:1459)
 n0: 53704448 in 58 places, all below massif's threshold (1.00%)

6 years agoChanges for converttif.c to fix tsize_t 975/head
szukw000 [Mon, 7 Aug 2017 14:44:28 +0000 (16:44 +0200)]
Changes for converttif.c to fix tsize_t

6 years agoopj_j2k_read_sot(): check current TPSot number regarding previous (non-zero) TNsot...
Even Rouault [Fri, 4 Aug 2017 16:01:29 +0000 (18:01 +0200)]
opj_j2k_read_sot(): check current TPSot number regarding previous (non-zero) TNsot to avoid opj_j2k_merge_ppt() to be called several times. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2851. Credit to OSS Fuzz

6 years agoFirst change on changes-for-afl-tests
szukw000 [Wed, 2 Aug 2017 15:27:08 +0000 (17:27 +0200)]
First change on changes-for-afl-tests

6 years agoUpdate abi-check to take into account new defaults for "add" git command
Antonin Descampe [Wed, 2 Aug 2017 15:07:29 +0000 (17:07 +0200)]
Update abi-check to take into account new defaults for "add" git command

6 years agoWIP: fix abi-check and automatic upload
Antonin Descampe [Wed, 2 Aug 2017 14:50:11 +0000 (16:50 +0200)]
WIP: fix abi-check and automatic upload

6 years agosrc/bin/jpwl/convert.c: add missing fclose() in error code path (suggested by maddin2...
Even Rouault [Mon, 31 Jul 2017 15:35:10 +0000 (17:35 +0200)]
src/bin/jpwl/convert.c: add missing fclose() in error code path (suggested by maddin200, #976)

6 years agoCatch images broken by AFL
szukw000 [Mon, 31 Jul 2017 11:58:08 +0000 (13:58 +0200)]
Catch images broken by AFL