summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/t2.c
AgeCommit message (Collapse)Author
2019-12-03Revert "Packet header writing: set empty packet header bit to 0 when ↵Carl Hetherington
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).
2017-08-17Sub-tile decoding: only decode precincts and codeblocks that intersect the ↵Even Rouault
window specified in opj_set_decode_area()
2017-08-16opj_t2_encode_packet(): fix potential write heap buffer overflow (#992)Even Rouault
2017-08-16opj_t2_encode_packet(): only emit an error about insufficiently large output ↵Even Rouault
buffer in FINAL_PASS mode. Fixes (master-only) regression added in 0b4fef6d1901254e41ab74ed681daba477d724c3
2017-08-10Fix argument order in error message of previous commitEven Rouault
2017-08-10Propagate event manager down to opj_t2_encode_packet() and use it to emit an ↵Even Rouault
error message when the output buffer is too small
2017-08-07Slight improvement in management of code block chunksEven Rouault
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%)
2017-08-07Decoding: do not allocate memory for the codestream of each codeblockEven Rouault
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%)
2017-08-07Add documentation for magic values in the codeEven Rouault
2017-07-30Fix Doxygen warnings (patch derived from Winfried's doxygen-dif.txt.zip, #849)Even Rouault
2017-07-26Avoid potential undefined shift behaviour in opj_bio_read() from ↵Even Rouault
opj_t2_read_packet_header() Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2485 Credit to OSS Fuzz
2017-06-13Merge branch 't1_flag_optimizations'Even Rouault
2017-06-12Packet header writing: set empty packet header bit to 0 when appropriate ↵fix_bypass_pterm_termall_and_lossless_decomposition_issueEven Rouault
(small optimization)
2017-06-12Encoder: fix packet writing of empty sub-bands (#891, #892)Even Rouault
There are situations where, given a tile size, at a resolution level, there are sub-bands with x0==x1 or y0==y1, that consequently don't have any valid codeblocks, but the other sub-bands may be non-empty. Given that we recycle the memory from one tile to another one, those ghost codeblocks might be non-0 and thus candidate for packet inclusion.
2017-06-02MQC/RAW decoder: use an artificial 0xFF 0xFF terminating marker.Even Rouault
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-05-09Reformat whole codebase with astyle.options (#128)Even Rouault
2016-05-08Fix Out-of-Bounds Access in function opj_tgt_resetmayeut
Fix uclouvain/openjpeg#775
2015-10-19Fix HP compiler warning about redeclaration of function (#640)Stephan Mühlstrasser
HP compiler warns: cc: "dwt.c", line 798: warning 562: Redeclaration of "opj_v4dwt_decode" with a different storage class specifier: "opj_v4dwt_decode" will have internal linkage. cc: "t2.c", line 1341: warning 562: Redeclaration of "opj_t2_init_seg" with a different storage class specifier: "opj_t2_init_seg" will have internal linkage.
2015-07-30Remove printf/fprintf to stdout/stderr throughout openjp2 libmayeut
Update uclouvain/openjpeg#246
2015-07-18Add some missing staticmayeut
Still needs to check j2k.c & jp2.c Update uclouvain/openjpeg#243
2014-11-20[trunk] fixed memleak in abnormal condition (fixes issue 437)Matthieu Darbois
2014-10-15[trunk] add a check on progression order (fixes issue 413)Antonin Descampe
2014-10-06[trunk] fixed potential negative size params (fixes issue 390)Antonin Descampe
2014-10-03[trunk]fixes buffer overflow in t2.cAntonin Descampe
Update issue 390 Summary: check for negative-size params in code Patch from Matthieu applied. Left open to apply this to other places in code.
2014-09-30[trunk] check possible overflow on size in opj_t2_read_packet_dataAntonin Descampe
Update issue 390 Labels: Priority-Critical Should be rechecked with ASan and pdfium
2014-09-30[trunk] prevent overflow in opj_t2_read_packet_header (update issue 389)Antonin Descampe
2014-09-29[trunk] Ensure cblk->data pointer is correctly initialized (updates issue ↵Antonin Descampe
391). Still need to check if it does not fail anymore with ASan.
2014-09-19added memory allocation checks (fixes issue 355)Antonin Descampe
2014-09-16[trunk] improve memory management (fixes issue 359)Antonin Descampe
2014-04-17[trunk] refactoring of rsiz, profiles, and extensions managementAntonin Descampe
2014-04-03[trunk] updated copyright and added copyright notice required by ISO, in ↵Antonin Descampe
each file; updated AUTHORS, NEWS
2014-03-18[trunk] Revert r2764. It breaks ~230 tests as seen on continuous. Since no ↵Mathieu Malaterre
dataset is available, the issue 296 will be left open. Update issue 296
2014-03-18[trunk] Import git commit fc884aee2b69c78500e65c3d05bf216791a9ea4a from ↵Mathieu Malaterre
ghostscript team Fixes issue 296
2014-03-18[trunk] Import git commit 99a6f1af177c15f4db475186b79d169c993494ef from ↵Mathieu Malaterre
ghostscript team Update issue 296
2014-03-14[trunk] Remove warnings about unused values introduced in r2710Mathieu Malaterre
Thanks to Matthieu Darbois for patch Fixes issue 290
2014-03-13[trunk] Just in case this would be helpful for other, here is the code used ↵Mathieu Malaterre
to track issue 80 Update issue 80
2014-03-13[trunk] Tweak documentation in t2.c. Be more verbose in case of failure.Mathieu Malaterre
2014-03-11[trunk] Re-active old warning about missing SOP markerMathieu Malaterre
2014-03-11[trunk] Add debug info to track issue 80Mathieu Malaterre
Update issue 80
2014-03-11[trunk] Rework assertion to work on 32bits systemMathieu Malaterre
2014-03-11[trunk] Fix remainings warnings on linux/32bits archMathieu Malaterre
2014-03-10[trunk] Another round of fixes for sign conversion warnings.Mathieu Malaterre
Update issue 256
2014-03-07[trunk] Rework r2597, make sure test suite is passing now.Mathieu Malaterre
Update issue 256
2014-03-07[trunk] Redo r2623, and remove guilty sectionMathieu Malaterre
Update issue 256
2014-03-07[trunk] Revert r2623 for nowMathieu Malaterre
2014-03-07[trunk] Another round of fixes for sign conversion warnings.Mathieu Malaterre
Update issue 256
2014-03-03[trunk] Remove remainings conversion issues in t2.c + clock.cMathieu Malaterre
2014-03-03[trunk] rework code to avoid a warning. this also remove a division and ↵Mathieu Malaterre
prefer bit-shift
2014-02-26[trunk] Remove a simple warning about a castMathieu Malaterre
2014-02-26[trunk] Revert r2453 since it breaks conformance test ETS-C1P1-p1_06.j2k-decodeMathieu Malaterre